我想打一個AUTO_INCREMENT列在數據庫表中,這裏是語法我寫:自動遞增列
create table comments
(
name varchar(20),
mail varchar(30),
comment varchar(100),
com_no int auto_increment
);
,我也得到了以下錯誤:
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
然後我做到了作爲主鍵:
create table comments
(
name varchar(20),
mail varchar(30),
comment varchar(100),
com_no int primary_key auto_increment
);
,我也得到了以下錯誤:
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 auto_increment,name varchar(20),mail varchar(30),comment varchar(100' at line 1
有什麼問題?
你使用了哪個數據庫? – Oded 2010-10-16 13:34:26
當你問一個特定於MySQL的問題時(因爲大多數其他SQL RDBMS不使用AUTO_INCREMENT),那麼你應該用mysql標籤標記你的問題。 – 2010-10-16 13:35:31