0

I have created the table and now I need to set 3 columns to require value without inserting again? I tryed typing:

ALTER TABLE _tablename_   
MODIFY COLUMN _columnname_ , _anotherone_ , .... NOT NULL;   

but it doesn't work that way.
It works perfectly fine if I do it for single column.

  • [See this answer](https://stackoverflow.com/a/3773498/939697) It is not possible to combine them into one line for the `MODIFY COLUMN` statement – Jake Feb 07 '18 at 22:08

1 Answers1

0

When you modify a column you have to specify all the attributes. There's no shortcut for just adding NOT NULL or doing the same change to multiple columns:

ALTER TABLE tablename
MODIFY column1 INT NOT NULL, 
MODIFY column2 VARCHAR(32) NOT NULL, 
MODIFY column3 VARCHAR(100) DEFAULT 'Not set' NOT NULL;
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Actually I tried it like that but I think i need to put _modify column_ text 3 times in my case if I want it to work... Correct me if I'm wrong – Zvone Pandza Feb 07 '18 at 22:19