本帖最后由 小鲁哥哥 于 2018-8-10 14:17 编辑
【济南校区】创建表以及外键
create table customer(
customerID varchar(32),
customerName varchar(255) null,
phone varchar(20) null,
address varchar(255) null,
contacts varchar(30) null,
other varchar(255) null,
primary key(customerID)
)
create table productType(
productTypeID varchar(32),
productTypeName varchar(100) null,
primary key(productTypeID)
)
create table product(
productID varchar(32) not null,
productTypeID varchar(32) null,
productName varchar(255) null,
producingArea varchar(255) null,
productOwner varchar(255) null,
make varchar(10) null,
price varchar(10) null,
quantity varchar(10) null,
other varchar(255) null,
primary key(productID)
)
create table orderi (
orderID varchar(32) not null,
customerID varchar(32) null,
productID varchar(32) null,
quantity varchar(10) null,
ordertime datetime null,
other varchar(255) null,
primary key (orderID)
)
create table quotation(
quotationID varchar(32),
productID varchar(32) null,
customerID varchar(32) null,
quotationMan varchar(32) null,
quotationtime datetime null,
other varchar(255) null,
primary key(quotationID)
)
alter table product
add foreign key (productTypeID) references producttype(productTypeID)
alter table orderi
add foreign key (customerID) references customer(customerID),
add foreign key (productID) references product(productID)
alter table quotation
add foreign key (customerID) references customer(customerID),
add foreign key (productID) references product(productID)
如果你想了解更多黑马课程,如果你想加入黑马这个大家庭学习先进技术,光交天下好友,那就快来吧!
黑马程序员济南中心联系电话:0531-55696830
|