Noelle Browne Noelle Browne - 23 days ago 16
MySQL Question

MYSQL: Error 1064(42000) MariaDB server for the right syntax to use near 'NOT NULL'

The whole error code says:

Error code
It's telling me I don't have the right syntax but here is my code what am I missing:

CREATE TABLE CONTACTAPPTABLE
(
MAId int unsigned NOT NULL AUTO_INCREMENT,
MAName varchar(50) DEFAULT NOT NULL,
MAEmail varchar(45) DEFAULT NOT NULL,
MASMS varchar(15) DEFAULT NOT NULL,
MAOpinion text DEFAULT NOT NULL,
MAOtherPaperCompanies varchar(20) DEFAULT NOT NULL,
MAStreetAddress varchar(20) DEFAULT NOT NULL,
MAColor varchar(20) DEFAULT NOT NULL,
MAZipCode varchar(20) DEFAULT NOT NULL,
MAMailingType varchar(20) DEFAULT NOT NULL,
MADT timestamp,
PRIMARY KEY(MAId)

)Engine=MyISAM AUTO_INCREMENT=1128 DEFAULT CHARSET=latin1;

Answer

You need to specify a default value:

NOT NULL DEFAULT "abc"

From the docs

column_definition:
    data_type [NOT NULL | NULL] [DEFAULT default_value]

edit in response to xQbert

According to MariaDB's docs,

MariaDB starting with 10.2.1
BLOB and TEXT columns can now have a DEFAULT value.

If you are running Maria < 10.2.1, you can not use DEFAULT on your TEXT data field.

Comments