CREATE TABLE IF NOT EXISTS customers (customer_id TEXT NOT NULL, time_stamp TIMESTAMP NOT NULL, customer_info TEXT), PRIMARY KEY (time_stamp)
The error is
mysql> CREATE TABLE IF NOT EXISTS customers (customer_id TEXT NOT NULL, time_stamp TIMESTAMP NOT NULL,
customer_info TEXT), PRIMARY KEY (time_stamp);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL 开发者_如何学Cserver version for the right syntax to use
near ' PRIMARY KEY (time_stamp)' at line 1
The primary key column needs to be defined within the CREATE TABLE
parentheses:
CREATE TABLE IF NOT EXISTS customers (
customer_id TEXT NOT NULL,
time_stamp TIMESTAMP NOT NULL,
customer_info TEXT,
PRIMARY KEY (time_stamp)
)
I'm curious why you didn't make customer_id
an indexable data type and therefore the primary key column...
精彩评论