[Err] 1005 - Can't create table 'xx' (errno: 150),求高手指教
/*用户表user的创建*/CREATETABLEuser(u_noINTNOTNULL,u_pwdVARCHAR(16)NOTNULL,u_nameVARCHAR(8)...
/*用户表user的创建*/
CREATE TABLE user(
u_no INT NOT NULL,
u_pwd VARCHAR(16) NOT NULL,
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)
);
/*好友列表friend的创建*/
CREATE TABLE friend
(
f_id INT NOT NULL,
u_noz INT NOT NULL,
u_noy INT NOT NULL,
f_date TIMESTAMP,
PRIMARY KEY(f_id),
FOREIGN KEY(u_noz) REFERENCES user(u_no),
FOREIGN KEY(u_noy) REFERENCES user(u_no)
);
CREATE TABLE diary(/*日记diary表的创建*/
r_id INT NOT NULL,
r_title VARCHAR(18) NOT NULL,
r_content TEXT NOT NULL,
r_date TIMESTAMP,
u_no INT NOT NULL,
PRIMARY KEY(r_id),
FOREIGN KEY(u_no) REFERENCES user(u_no)
);
CREATE TABLE album(/*相册album表的创建*/
x_id INT NOT NULL,
x_name VARCHAR(18) NOT NULL,
u_no INT NOT NULL,
x_access INT DEFAULT 0, -- 0:公开,1:好友,2:仅自己可见
x_date TIMESTAMP,
PRIMARY KEY(x_id),
FOREIGN KEY(u_no) REFERENCES user(u_no)
);
CREATE TABLE photo(/*照片photo表的创建 展开
CREATE TABLE user(
u_no INT NOT NULL,
u_pwd VARCHAR(16) NOT NULL,
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)
);
/*好友列表friend的创建*/
CREATE TABLE friend
(
f_id INT NOT NULL,
u_noz INT NOT NULL,
u_noy INT NOT NULL,
f_date TIMESTAMP,
PRIMARY KEY(f_id),
FOREIGN KEY(u_noz) REFERENCES user(u_no),
FOREIGN KEY(u_noy) REFERENCES user(u_no)
);
CREATE TABLE diary(/*日记diary表的创建*/
r_id INT NOT NULL,
r_title VARCHAR(18) NOT NULL,
r_content TEXT NOT NULL,
r_date TIMESTAMP,
u_no INT NOT NULL,
PRIMARY KEY(r_id),
FOREIGN KEY(u_no) REFERENCES user(u_no)
);
CREATE TABLE album(/*相册album表的创建*/
x_id INT NOT NULL,
x_name VARCHAR(18) NOT NULL,
u_no INT NOT NULL,
x_access INT DEFAULT 0, -- 0:公开,1:好友,2:仅自己可见
x_date TIMESTAMP,
PRIMARY KEY(x_id),
FOREIGN KEY(u_no) REFERENCES user(u_no)
);
CREATE TABLE photo(/*照片photo表的创建 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询