【MySQL作业】DDL 和 DML——美和易思使用 DDL 维护数据库表结构应用习题
点击打开所使用到的数据库>>>
1、使用 DDL 语句修改 easyShopping 商品表 goods 表结构,要求如下:
- 新增字段生产厂商 manufacturer,它的类型为 varchar(50)。
- 将字段 unitPrice 更名为 price,字段类型维持不变,仍为 decimal(8,2) 类型。
- 将字段 category 的类型修改为 varchar(50)。
- 删除字段 saleCount。
- 删除定义在 goodsName 字段的唯一约束,约束名为 unique_gName。
use easyShopping;
alter table goods
add manufacturer varchar(50),
change unitPrice price decimal(8,2),
modify category varchar(50),
drop column saleCount,
drop unique unique_gName
2、使用 DDL 语句创建订单表,然后在订单表的客户编号上创建一个参照客户表的外键约束。
alter table orders
add constraint fk_orders_customer
foreign key(customerID) references
customer(customerID)
3、删除定义在订单表客户编号上的外键约束。
alter table orders drop foreign key fk_orders_customer
>>知识点【第3章 DDL 和 DML】
本文来自博客园,作者:明金同学,转载请注明原文链接:https://www.cnblogs.com/vmuu/p/15663635.html
公众号:【明金同学】