资源描述:
《SQL-Server2012综合练习题2 - 参考答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、SQLServer练习题2一.建库建表:1.向数据库CPXS中的产品表CP加入数据。产品表CPCPBHCPMCJGKCL100001彩色电视机3000.010100002洗衣机1200.020100003冰箱1800.012100004电热水器2000.030100005太阳能热水器2200.081000061匹空调1800.051000071.5匹空调2400.0201000082匹空调3800.06100009音响3500.03100010台式计算机6000.05100011MP3300.010100012
2、复读机200.020----插入CP表记录USECPXSGOINSERTINTOCPVALUES('100001','彩色电视机',3000.0,10)GOINSERTINTOCPVALUES('100002','洗衣机',1200.0,20)GOINSERTINTOCPVALUES('100003','冰箱',1800.0,12)GOINSERTINTOCPVALUES('100004','电热水器',2000.0,30)GOINSERTINTOCPVALUES('100005','太阳能热水器',2200.
3、0,8)GOINSERTINTOCPVALUES('100006','1匹空调',1800.0,5)GOINSERTINTOCPVALUES('100007','1.5匹空调',2400.0,20)GOINSERTINTOCPVALUES('100008','2匹空调',3800.0,6)GOINSERTINTOCPVALUES('100009','音响',3500.0,3)GOINSERTINTOCPVALUES('100010','台式计算机',6000.0,5)GOINSERTINTOCPVALUES('
4、100011','MP3',300.0,10)GOINSERTINTOCPVALUES('100012','复读机',200.0,20)GO1.向数据库CPXS中的销售商表XSS加入数据。销售商表XSSXSBHXSMCDQFZRDHBZ000001广电公司南京张建025111111NULL000002家电市场无锡李思成051022222NULL000003电器商场上海王京平021333333NULL000004小家电市场南京赵雅如025666666NULL----插入XSS表记录USECPXSGOINSERTI
5、NTOXSSVALUES('000001','广电公司','南京','张建','025111111',NULL)GOINSERTINTOXSSVALUES('000002','家电市场','无锡','李思成','051022222',NULL)GOINSERTINTOXSSVALUES('000003','电器商场','上海','王京平','021333333',NULL)GOINSERTINTOXSSVALUES('000004','小家电市场','南京','赵雅如','025666666',NULL)GO1
6、.向数据库CPXS中的销售商表XSS加入数据。产品销售表XSCPCPBHXSBHXSSJSLJE1000010000012009-03-1013000.01000010000032009-05-2026000.01000020000012009-03-1211200.01000020000022009-02-2222400.01000020000032009-05-2933600.01000110000042009-06-0151000.0----插入XSCP表记录:USECPXSGOINSERTINTOXSC
7、PVALUES('100001','000001','2009-03-10',1,3000.0)GOINSERTINTOXSCPVALUES('100001','000003','2009-05-20',2,6000.0)GOINSERTINTOXSCPVALUES('100002','000001','2009-03-12',1,1200.0)GOINSERTINTOXSCPVALUES('100002','000002','2009-02-22',2,2400.0)GOINSERTINTOXSCPVALUE
8、S('100002','000003','2009-05-29',3,3600.0)GOINSERTINTOXSCPVALUES('100011','000004','2009-06-01',5,1000.0)GO二.修改记录1.修改CP表的记录:1000061匹空调1500.05100012复读机200.015----修改记录USECPXSGOUPDATECPSETJG=1500.0