开发者

What's wrong with the SQL?

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜