Trying to create a table that has DATE attribute release
.
I want to default this date to some fixed date (specifically 9999-12-31
) but I get an SQL syntax error using the following method:
CREATE TABLE price(
...
release DATE DEFAULT '99991231',
...
);
The little searching I've done has only shown me how to default to current date or some form of a dynamic date but I'm just looking for a way to default to a fixed date.
EDIT more detail:
CREATE TABLE game(gid INT NOT NULL AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
release DATE NOT NULL DEFAULT '9999-12-31',
platform VARCHAR(128) NOT NULL,
released BOOLEAN DEFAULT FALSE,
PRIMARY KEY(gid)
);
I get the following error after issuing the command: mysql -u root -p trade < game.sql
ERROR 1064 (42000) at line 1: 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 'release DATE NOT NULL DEFAULT '9999-12-31',
platform VARCHAR(' at line 3
where trade is the name of an empty database and mysql --version
yields the output mysql Ver 14.14 Distrib 5.5.47, for debian-linux-gnu (x86_64) using readline 6.3
Here a sample with backticks:
CREATE TABLE `r` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`release` DATE NOT NULL DEFAULT '9999-01-01',
`comment` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB AUTO_INCREMENT=1234567892 DEFAULT CHARSET=utf8;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.