表结构的修改,删除,编辑

 /*drop database CPXS*/
create database CPXS
use CPXS
go
create table CP
(
产品编号 char(6) not null primary key ,
产品名称 char(30) not null,
价格 float(8) null,
库存量 int null
)
go
create table XSS
(客户编号 char(6) not null,
客户名称 char(30) not null,
地区 char(10) null,
负责人 char(8),
电话 char(12)
)
go

alter table XSS
add constraint pk_客户编号 primary key(客户编号)
go

create table  CPXSB
(产品编号 char(6) not null foreign key references CP(产品编号) on delete cascade  ,
客户编号 char(6) not null foreign key references XSS(客户编号) on delete cascade ,
销售日期 datetime not null,
数量 int ,
销售额 float
)
go

alter table  CPXSB
add constraint fk_CPXSB primary key(产品编号,客户编号,销售日期)
go


insert into CP values ('200001','柜式空调',3000,200)
insert into CP values ('200002','微波炉',1000,100)
insert into CP values ('200003','抽油烟机',1200,50)

go

alter table CP
add 产品简列 varchar(50) NULL
go

update CP set 价格=价格*0.8

go

delete from CP where 产品编号 in (select 产品编号 from CP where 价格*0.9 <1500)

go

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值