简体   繁体   English

SQL怎么了?

[英]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 server 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括号内定义主键列:

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... 我很好奇为什么您没有将customer_id为可索引的数据类型,因此没有将主键列设置为...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM