资源描述:
《《数据库原理及应用》实验指导》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、理学院信科08—2班陈先国3080942214实验1创建数据库与数据表下面写出实现如下操作的SQL语句:(1)创建供应系统“GYXT”数据库。CREATEDATABASEGYXTON(NAME=GYXT_data,FILENAME=’D:GYXT.mdf’,SIZE=10,MAXSIZE=50,FILEGROWTH=5)LOGON(NAME=GYXT_Log,FILENAME=’D:GXTYData.ldf’,SIZE=5,MAXSIZE=25,FILEGROWTH=5);(2)建立供应商表S。CREATETABLES(SNOchar(5)notnullunique,SNAME
2、char(20)notnullunique,CITYchar(20));INSERTINTOSVALUES('S1','精益','天津');INSERTINTOSVALUES('S2','万胜','北京');INSERTINTOSVALUES('S3','东方','北京');INSERTINTOSVALUES('S4','丰泰隆','上海');INSERTINTOSVALUES('S5','康健','南京');(3)建立零件表P。CREATETABLEP(PNOchar(2)notnullPRIMARYKEY(PNO),PNAMEchar(20),COLORchar(20),WEI
3、GHTsmallint);INSERTINTOPVALUES('P1','螺母','红',12);INSERTINTOPVALUES('P2','螺栓','绿',17);11INSERTINTOPVALUES('P3','螺丝刀','蓝',14);INSERTINTOPVALUES('P4','螺丝刀','红',14);INSERTINTOPVALUES('P5','凸轮','蓝',40);INSERTINTOPVALUES('P6','齿轮','红',30);(4)建立工程项目表J。CREATETABLEJ(JNOchar(5)notnullunique,JNAMEchar(20
4、)notnullunique,CITYchar(20));INSERTINTOJVALUES('J1','三建','北京');INSERTINTOJVALUES('J2','一汽','长春');INSERTINTOJVALUES('J3','弹簧厂','天津');INSERTINTOJVALUES('J4','造船厂','天津');INSERTINTOJVALUES('J5','机车厂','唐山');INSERTINTOJVALUES('J6','无线电厂','常州');INSERTINTOJVALUES('J7','半导体厂','南京');(5)建立供应情况表SPJ。CREATE
5、TABLESPJ(SNOchar(5),PNOchar(5),JNOchar(5),QTYint);INSERTINTOSPJVALUES('S1','P1','J1','200');INSERTINTOSPJVALUES('S1','P1','J3','100');INSERTINTOSPJVALUES('S1','P1','J4','700');INSERTINTOSPJVALUES('S1','P2','J2','100');INSERTINTOSPJVALUES('S2','P3','J1','400');INSERTINTOSPJVALUES('S2','P3','J2'
6、,'200');INSERTINTOSPJVALUES('S2','P3','J4','500');INSERTINTOSPJVALUES('S2','P3','J5','400');INSERTINTOSPJVALUES('S2','P5','J1','400');INSERTINTOSPJVALUES('S2','P5','J2','100');INSERTINTOSPJVALUES('S3','P1','J1','200');INSERTINTOSPJVALUES('S3','P3','J1','200');INSERTINTOSPJVALUES('S4','P5','J1'
7、,'100');INSERTINTOSPJVALUES('S4','P6','J3','300');INSERTINTOSPJVALUES('S4','P6','J4','200');INSERTINTOSPJVALUES('S5','P2','J4','100');11INSERTINTOSPJVALUES('S5','P3','J1','200');INSERTINTOSPJVALUES('S5','P6','J2','200');INSERTINTOSPJVAL