Reputation: 21
When I create a table in phpMyAdmin, I receive this error:
#1067 - Invalid default value for 'htmlstate'
Query to create table:
CREATE TABLE `cms_article` (
`contentid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pagetext` mediumtext /*!40101 COLLATE latin1_bin */ NOT NULL,
`threadid` int(10) unsigned DEFAULT NULL,
`blogid` int(10) unsigned DEFAULT NULL,
`posttitle` varchar(255) /*!40101 COLLATE latin1_bin */ DEFAULT NULL,
`postauthor` varchar(100) /*!40101 COLLATE latin1_bin */ DEFAULT NULL,
`poststarter` int(10) unsigned DEFAULT NULL,
`blogpostid` int(10) unsigned DEFAULT NULL,
`postid` int(10) unsigned DEFAULT NULL,
`post_posted` int(10) unsigned DEFAULT NULL,
`post_started` int(10) unsigned DEFAULT NULL,
`previewtext` varchar(2048) /*!40101 COLLATE latin1_bin */ DEFAULT NULL,
`previewimage` varchar(256) /*!40101 COLLATE latin1_bin */ DEFAULT NULL,
`imagewidth` int(10) unsigned DEFAULT NULL,
`imageheight` int(10) unsigned DEFAULT NULL,
`previewvideo` mediumtext /*!40101 COLLATE latin1_bin */,
`htmlstate` enum('off','on','on_nl2br') /*!40101 COLLATE latin1_bin */ NOT NULL DEFAULT 'off',
PRIMARY KEY (`contentid`)
) ENGINE=InnoDB AUTO_INCREMENT=503 /*!40101 DEFAULT CHARSET=latin1 */ /*!40101 COLLATE=latin1_bin */;
Upvotes: 2
Views: 4232
Reputation: 1269953
In earlier versions of MySQL, you can just declare it NOT NULL
:
If an ENUM column is declared to permit NULL, the NULL value is a legal value for the column, and the default value is NULL. If an ENUM column is declared NOT NULL, its default value is the first element of the list of permitted values.
(From here.)
The first value 'off'
will be used in your case.
Upvotes: 1