看看这个MYSQL建表语句,总是错误
createtablecustomers(cust_numintnotNULL,companyvarchar(20)notNULL,cust_repint,credit_...
create table customers
(
cust_num int not NULL,
company varchar(20) not NULL,
cust_rep int,
credit_limit int,
primary key(cust_num),
foreign key hasrep(cust_rep)references salesreps on delete set NUll
)
create table offices
(
office int not NULL,
city varchar(15) not NULL,
region varchar(10) not NULL,
mgr int,
target int,
sales int not NULL,
primary key(office),
foreign key hasmgr(mgr) references salesreps on delete set NULL
)
create table salesreps
(
empl_num int not NULL,
name varchar(15) not NULL,
age int,
rep_office int,
title varchar(10),
hire_date date not NULL,
manager int,
quota int,
sales money not NULL,
primary key(empl_num),
foreign key(manager) references salesreps on delete set NULL,
foreign key worksin(rep_office) references offices on delete set NULL
)
create table orders
(
order_num int not null,
order_date date not null,
cust int not null,
rep int,
mfr char(3) not null,
produce char(5) not null,
qty int not null,
amount int not null,
primary key (order_num),
foreign key placedby(cust) references customers on delete cascade,
foreign key takenby(rep) references salesreps on delete set null,
foreign key isfor(mfr,product) references products on delete restrict
)
create table products
(
mfr_id char(3) not Null,
product_id char(5) not NULL,
description varchar(20) not null,
price int not null,
qty_on_hand int not null,
primary key(mfr_id,product_id)
);
————————————————————————————————
phpmyadmin总是返回
MySQL 返回:
#1064 - 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 'create table offices
(
office int not NULL,
city varchar(15) not NULL,
regio' at line 11
每一条语句后面加上分号后,新的提示:
MySQL 返回:
#1005 - Can't create table '.\sql the complete reference\customers.frm' (errno: 150) 展开
(
cust_num int not NULL,
company varchar(20) not NULL,
cust_rep int,
credit_limit int,
primary key(cust_num),
foreign key hasrep(cust_rep)references salesreps on delete set NUll
)
create table offices
(
office int not NULL,
city varchar(15) not NULL,
region varchar(10) not NULL,
mgr int,
target int,
sales int not NULL,
primary key(office),
foreign key hasmgr(mgr) references salesreps on delete set NULL
)
create table salesreps
(
empl_num int not NULL,
name varchar(15) not NULL,
age int,
rep_office int,
title varchar(10),
hire_date date not NULL,
manager int,
quota int,
sales money not NULL,
primary key(empl_num),
foreign key(manager) references salesreps on delete set NULL,
foreign key worksin(rep_office) references offices on delete set NULL
)
create table orders
(
order_num int not null,
order_date date not null,
cust int not null,
rep int,
mfr char(3) not null,
produce char(5) not null,
qty int not null,
amount int not null,
primary key (order_num),
foreign key placedby(cust) references customers on delete cascade,
foreign key takenby(rep) references salesreps on delete set null,
foreign key isfor(mfr,product) references products on delete restrict
)
create table products
(
mfr_id char(3) not Null,
product_id char(5) not NULL,
description varchar(20) not null,
price int not null,
qty_on_hand int not null,
primary key(mfr_id,product_id)
);
————————————————————————————————
phpmyadmin总是返回
MySQL 返回:
#1064 - 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 'create table offices
(
office int not NULL,
city varchar(15) not NULL,
regio' at line 11
每一条语句后面加上分号后,新的提示:
MySQL 返回:
#1005 - Can't create table '.\sql the complete reference\customers.frm' (errno: 150) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询