如何避免这种情况MySQL错误列名“ COLUMN NAME列的说明符不正确?
技术问答
296 人阅读
|
0 人回复
|
2023-09-14
|
如何避免这种情况MySQL错误 列topic_id列的说明符不正确 ?
% L& q4 b& S9 x, {! f6 N! ?, o' HMSQL错误…# t c% H2 ^* @: M/ f' b
#1063 - Incorrect column specifier for column 'topic_id'SQL模式…
0 U" W* V1 o2 h" ACREATE TABLE discussion_topics topic_id char(36) NOT NULL AUTO_INCREMENT, project_id char(36) NOT NULL, topic_subject VARCHAR(255) NOT NULL, topic_content TEXT default NULL, date_created DATETIME NOT NULL, date_last_post DATETIME NOT NULL, created_by_user_id char(36) NOT NULL, last_post_user_id char(36) NOT NULL, posts_count char(36) default NULL, PRIMARY KEY (topic_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1.
5 P- v- q' _2 z0 A4 U& Q, S 解决方案:
& b8 c1 f' R0 b& l/ ] 要使用它,AUTO_INCREMENT您需要将column定义为asINT或者浮点类型,而不是CHAR。
6 l n2 _ \' N. n. Y. ?AUTO_INCREMENT只使用无符号值,所以也很容易使用UNSIGNED;8 E ~" q w2 k% q7 U+ F) ^
CREATE TABLE discussion_topics ( topic_id INT NOT NULL unsigned AUTO_INCREMENT, project_id char(36) NOT NULL, topic_subject VARCHAR(255) NOT NULL, topic_content TEXT default NULL, date_created DATETIME NOT NULL, date_last_post DATETIME NOT NULL, created_by_user_id char(36) NOT NULL, last_post_user_id char(36) NOT NULL, posts_count char(36) default NULL, PRIMARY KEY (topic_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1. |
|
|
|
|
|