数据库实验二 通过sql语句创建与管理数据表

数据库实验二 通过sql语句创建与管理数据表

ID:18307111

大小:266.58 KB

页数:9页

时间:2018-09-16

数据库实验二 通过sql语句创建与管理数据表_第1页
数据库实验二 通过sql语句创建与管理数据表_第2页
数据库实验二 通过sql语句创建与管理数据表_第3页
数据库实验二 通过sql语句创建与管理数据表_第4页
数据库实验二 通过sql语句创建与管理数据表_第5页
资源描述:

《数据库实验二 通过sql语句创建与管理数据表》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、实验二通过SQL语句创建与管理数据表一、实验目的(1)掌握查询分析器的使用。(2)掌握通过SQL语句创建表的方法。(3)掌握通过SQL语句修改表结构的方法。(4)掌握通过SQL语句添加、修改、删除表数据的方法。二、实验内容1、通过SQL语句删除表用SQL语句在数据库StudentStudent_info中删除实验一创建的studentStudent表、courseCourse表、SC表。droptableSC_20103322droptableStudent_20103322droptableCourse_201

2、033222、通过SQL语句创建表用SQL语句在数据库StudentStudent_info中创建实验一中的studentStudent表、courseCourse表、SC表,结构如实验一中表2、表3、表4所示表2:createtableStudent_20103322(Snochar(8)notnullprimarykey,--学号loanapprovalandpostcreditapprovalofficer/atalllevelsinaccordancewithcreditapprovalrules,lic

3、ensingandeventualexerciseofcreditdecisionpowerofpersonsorinstitutions.Reviewfindingsandreviewcomments,accordingtotheBank'screditSnamevarchar(8)notnull,--学生姓名Sexchar(2)notnulldefault'男',--性别Birthsmalldatetimenotnull,--出生年月Classnochar(3)notnull,--班级号Entrance_da

4、tesmalldatetimenotnull,--入学时间Homeaddrvarchar(40)notnull,--家庭住址)表3:createtableCourse_20103322(Cnochar(3)notnullprimarykey,--课程号Cnamevarchar(20)notnull,--课程名称Total_periorsmallint,--总学时Credittinyint,--学分check(Total_perior>3andCredit>0andCredit<=6))loanapprovalan

5、dpostcreditapprovalofficer/atalllevelsinaccordancewithcreditapprovalrules,licensingandeventualexerciseofcreditdecisionpowerofpersonsorinstitutions.Reviewfindingsandreviewcomments,accordingtotheBank'scredit表4:createtableSC_20103322(primarykey(Sno,Cno),Snochar(

6、8)notnullforeignkeyreferencesStudent_20103322(Sno),--学号Cnochar(3)notnullforeignkeyreferencesCourse_20103322(Cno),--课程号Gradetinyint,--成绩check(Grade>=0andGrade<=100))loanapprovalandpostcreditapprovalofficer/atalllevelsinaccordancewithcreditapprovalrules,licensi

7、ngandeventualexerciseofcreditdecisionpowerofpersonsorinstitutions.Reviewfindingsandreviewcomments,accordingtotheBank'scredit3、通过SQL语句管理表结构(1)添加和删除列a.给studentStudent表增加身高(以米单位)statureStature列,类型为numeric(4,2),允许为空值,且身高值需小于3.0米。altertableStudent_20103322addStatu

8、renumeric(4,2),constraintck_Staturecheck(Stature<3.0)b.给studentStudent表增加所在系Sdept列,字符型,长度2,不允许为空值。altertableStudent_20103322addSdeptchar(8)notnullc.给studentStudent表增加邮政篇码Postcode列,字符型,长度为

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。