CREATE TABLE IF NOT EXISTS customers (customer_id TEXT NOT NULL, time_stamp TIMESTAMP NOT NULL, customer_info TEXT), PRIMARY KEY (time_stamp)
错误是
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 server version for the right syntax to use
near ' PRIMARY KEY (time_stamp)' at line 1
答案 0 :(得分:4)
主键列需要在CREATE TABLE
括号内定义:
CREATE TABLE IF NOT EXISTS customers (
customer_id TEXT NOT NULL,
time_stamp TIMESTAMP NOT NULL,
customer_info TEXT,
PRIMARY KEY (time_stamp)
)
我很好奇为什么你没有使customer_id
成为可索引的数据类型,因此也就是主键列......