MYSQL5.1 建立新表时出现的问题,新手求大神解惑~
mysql>CREATETABLEuser(->u_noINTNOTNULL,->u_pwdVARCHAR(16),->u_nameVARCHAR(8),->u_emai...
mysql> CREATE TABLE user(
-> u_no INT NOT NULL,
-> u_pwd VARCHAR(16),
-> u_name VARCHAR(8),
-> u_email VARCHAR(18),
-> u_state TINYTEXT,
-> h_id INT,
-> PRIMARY KEY(u_no),
-> FOREIGE KEY(h_id) REFERENCES head(h_id)
-> );
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 'KEY(h
_id) REFERENCES head(h_id)
)' at line 9 展开
-> u_no INT NOT NULL,
-> u_pwd VARCHAR(16),
-> u_name VARCHAR(8),
-> u_email VARCHAR(18),
-> u_state TINYTEXT,
-> h_id INT,
-> PRIMARY KEY(u_no),
-> FOREIGE KEY(h_id) REFERENCES head(h_id)
-> );
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 'KEY(h
_id) REFERENCES head(h_id)
)' at line 9 展开
展开全部
--FOREIGE写错了
CREATE TABLE user(
u_no INT NOT NULL,
u_pwd VARCHAR(16),
u_name VARCHAR(8),
u_email VARCHAR(18),
u_state TINYTEXT,
h_id INT,
PRIMARY KEY(u_no),
FOREIGN KEY(h_id) REFERENCES head(h_id) --已修正为FOREIGN
);
更多追问追答
追问
大神已改但是又出现了个.....
mysql> use kdwb
Database changed
省略----
ERROR 1005 (HY000): Can't create table 'kdwb.user' (errno: 150)
mysql>
肿么破
追答
有外键的情况下建表,很容易出现这个问题。首先你要排除字段类型是否一致,然再
你参考一下这个链接
http://blog.csdn.net/hzx5212/article/details/9469709
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询