On mysql site I need to add column not alowing null and on lines :
ALTER TABLE quizzes.docs ADD doc_code varchar(10) DEFAULT ‘-’ NOT NULL;
ALTER TABLE quizzes.docs CHANGE doc_code doc_code varchar(10) DEFAULT ‘-’ NULL AFTER employee_id;
with error :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line
how to fix this ?
8.0.36-0ubuntu0.22.04.1
Thanks in advance!
This
ALTER TABLE quizzes.docs CHANGE doc_code doc_code varchar(10) DEFAULT ‘-’ NULL AFTER employee_id;
Change into
ALTER TABLE quizzes.docs MODIFY COLUMN doc_code varchar(10) DEFAULT '-' NOT NULL;
But if column is not exist you should add column and change ‘ into '
ALTER TABLE quizzes.docs ADD COLUMN doc_code varchar(10) DEFAULT '-' NOT NULL AFTER employee_id;