I have a standard LAMP configuration (apache2, mysql, php5), running on ubuntu, and I'm just typing mysql commands into my terminal. I'm logged into the mysql command line as root. So far I've created a new database, but now trouble started.
I'm trying to create a simple table but am getting a mysql syntax error and can't figure out what I'm doing wrong.
This is the error:
ERROR 1064 (42000): 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 ')' at line 10
And this is my query:
CREATE TABLE IF NOT EXISTS `customers` (
`uid` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`phone` varchar(100) NOT NULL,
`password` varchar(200) NOT NULL,
`address` varchar(50) NOT NULL,
`city` varchar(50) NOT NULL,
`created` datetime NOT NULL DEFAULT TIMESTAMP
);
No idea what's wrong honestly.
You can assign default value as current_timestamp
not just timestamp
CREATE TABLE IF NOT EXISTS `customers` (
`uid` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`phone` varchar(100) NOT NULL,
`password` varchar(200) NOT NULL,
`address` varchar(50) NOT NULL,
`city` varchar(50) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments