您的位置:首页 > 其它

创建数据表添加unsigned时需要注意的

2014-03-23 17:00 429 查看
创建mysql数据表 错误语句:
create  table blog_article(id int(11) not null UNSIGNED
primary key auto_increment,typeid varchar(250),title
varchar(250), content text not null,author
varchar(250),leavetime int(11));
错误提示 mysql的提示还真够让你折腾的

mysql> create table blog_comment(id int(11)  not null UNSIGNED primary key auto_increment,article_id int(11) UNSIGNED,username varchar(250),
time int(11) UNSIGNED,pid int(11));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right synta
x to use near 'UNSIGNED primary key auto_increment,article_id int(11) UNSIGNED,username varchar' at line 1
这里的错误是由于unsigned 的位置放错造成的,unsigned应该放在数据类型的第一位,不然会提示错误
正确语句:
create  table blog_article(id int(11) UNSIGNED  not null
primary key auto_increment,typeid varchar(250),title
varchar(250), content text not null,author
varchar(250),leavetime int(11));


本文出自 “Freax” 博客,请务必保留此出处http://freax.blog.51cto.com/6614733/1381809
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: