欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    SQL第四章课后习题答案.docx

    • 资源ID:18959553       资源大小:19.09KB        全文页数:23页
    • 资源格式: DOCX        下载积分:8.8金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要8.8金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    SQL第四章课后习题答案.docx

    SQL第四章课后习题答案USEstudentGOCREATETABLEstud_info(stud_idCHAR(10)NOTNULL,nameNVARCHAR(4)NOTNULL,birthdayDATETIME,genderNCHAR(1),addressNVARCHAR(20),telcodeCHAR(12),zipcodeCHAR(6),markDECIMAL(3,0)-1、利用资源管理器创立表-2.、删除表和创立表usestudentgodroptablestud_infogousestudentgodroptableclassroom_infogousestudentgodroptabledept_codegousestudentgodroptablelesson_infogousestudentgodroptablespecialty_codegousestudentgodroptablestaffroom_infogousestudentgodroptablestud_gradegousestudentgodroptableteacher_infogousestudentgodroptableteacher_schedulegoUSEstudentGOCREATETABLEstud_info(stud_idCHAR(10)NOTNULL,nameNVARCHAR(4)NOTNULL,birthdayDATETIME,genderNCHAR(1),addressNVARCHAR(20),telcodeCHAR(12),zipcodeCHAR(6),markDECIMAL(3,0)USEstudentGOCREATETABLEteacher_info(teacher_idCHAR(10)NOTNULL,nameNVARCHAR(4)NOTNULL,genderNCHAR(1),ageint,tech_titlenchar(5),telephonevarchar(12),salarydecimal(7),course_idchar(10)usestudentgocreatetablestud_grade(stud_idchar(10)notnull,namenvarchar(4)notnull,course_idchar(10),gradenumeric(4)usestudentgocreatetablelesson_info(course_idchar(10)notnull,course_namenvarchar(12)notnull,course_typenchar(2)notnull,course_markintnotnull,course_timedecimal(3)usestudentgocreatetableteach_schedule(course_idchar(10)notnull,course_datedatetime,course_weekint,room_idchar(6),deptcodechar(2),teacher_idchar(6)usestudentgocreatetabledept_code(deptcodechar(2)notnull,deptnamenvarchar(10),)usestudentgocreatetablespecialty_code(speccodechar(10)notnull,specnamenvarchar(10)usestudentgocreatetablestaffroom_info(jysh_idchar(4)notnull,jysh_namenvarchar(10),jysh_typenchar(2),jysh_leadernvarchar(4)usestudentgocreatetableclassroom_info (room_idchar(6)notnull,room_namenvarchar(8),room_typenvarchar(6),room_devicenvarchar(10),room_sizeint)usestudentgocreatetablestud_exam(exam_coursenvarchar(10),exam_typenvarchar(6),exam_quantityint,exam_timedatetime,exam_idchar(10),exam_teachernvarchar(10),exam_classroomnvarchar(8),exam_rulenvarchar(10),exam_jilunvarchar(20)-、分别使用对象资源管理器和T语句修改表构造-(1)、将teacher_info表中的teacher_id列长度从6个字符改变到8个字符altertableteacher_infoaltercolumnteacher_idchar(8)-(2)、在dept_code表中加最后一列dept_memo,其数据类型为可变长度字符型,30位altertabledept_codeadddept_memonvarchar(30)-(3)、向stud_info表中增加“入学时间列,其数据类型为日期型altertablestud_infoaddschooldatedatetime-假设在创立数据表lesson_info时错将课程学分course_mark设计为char(2),现欲修改为decimal(3,1)altertablelesson_infoaltercolumncourse_markdecimal(3,1)-(4).建立约束-(4)1、为student数据库的stud_info表中的mark列建立check约束altertablestud_infoaddconstraintch_markcheck(markbetween560and600);-(4).2、使用T-SQL语句创立表stud_info,设置stud_info为primarykey约束usestudentgodroptablestud_infogoUSEstudentGOCREATETABLEstud_info(stud_idCHAR(10)NOTNULLconstraintpk_stud_idprimarykey,nameNVARCHAR(4)NOTNULL,birthdayDATETIME,genderNCHAR(1),addressNVARCHAR(20),telcodeCHAR(12),zipcodeCHAR(6),markDECIMAL(3,0)-(4).3为表stud_info的telcode列建立UNIQUE约束altertablestud_infoaddconstraintun_telephoneunique(telcode)-(4).4为stud_grade表中的stud_id列建立foreignkey约束altertablestud_gradeaddconstraintfk_stud_idforeignkey(stud_info)referencesstud_info(stud_id)-独立实践:altertablestud_infoadddefault(null)forzipcode-(5).插入数据-(5).1insertintostud_infovalues('0401010811',N'张源','12-05-1986',N'男',N'北京市海淀区','010-*','100080',560)select*fromstud_info-独立实践:USEstudentGOINSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401010811',N'张源','12-05-1986',N'男',N'北京市海淀区','010-*','100080',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401020201',N'赵明','08-06-1986',N'男',N'上海市浦东区','021-*','202100',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401030101',N'王刚','01-02-1986',N'男',N'天津市南开区','022-*','300000',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401050201',N'陈红','10-25-1986',N'女',N'武汉市汉口区','027-*','430000',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401040112',N'孙强','06-07-1986',N'男',N'重庆市沙坪坝','023-*','400000',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401020203',N'李伟','09-01-1986',N'男',N'北京市大兴县','010-*','102600',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401010634',N'钱昆','12-06-1986',N'男',N'广州市海珠区','020-*','510000',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401030213',N'郑芳','08-09-1986',N'女',N'江苏省南京市','025-*','210000',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401010102',N'袁飞','03-11-1986',N'男',N'湖南省长沙县','0731-*','410000',560);INSERTINTO"STUD_INFO"("STUD_ID","NAME","BIRTHDAY","GENDER","ADDRESS","TELCODE","ZIPCODE","MARK")VALUES('0401040123',N'孔荣','05-31-1986',N'男',N'云南省昆明市','0871-*','650000',600);-(5).2insertintoteacher_infovalues('010101',N'刘娜',N'女',34,N'讲师','020-*',418,'0401010102')select*fromteacher_info-独立实践:USEstudentGOinsertintoteacher_infovalues('010102',N'邵云鹏',N'男',45,N'教授','020-34607811',418,'0401010105');insertintoteacher_infovalues('010103',N'孙乐多',N'男',27,N'助教','020-34602622',418,'0401010106');insertintoteacher_infovalues('010104',N'赵一欧',N'女',26,N'助教','020-34603472',418,'0401010101');insertintoteacher_infovalues('010106',N'王吉林',N'男',32,N'讲师','020-34603232',418,'0401010103');insertintoteacher_infovalues('010105',N'王小悦',N'女',35,N'讲师','020-34603790',418,'0401010104');-(5).3USEstudentGOINSERTINTOclassroom_infoVALUES('120703',N'微机组装与维护',N'实训',N'微机、投影仪',40);INSERTINTOclassroom_infoVALUES('120704',N'计算机网络',N'实验',N'交换机、路由器等',40);INSERTINTOclassroom_infoVALUES('120705',N'数据库',N'计算机机房',N'微机、投影仪',60);INSERTINTOclassroom_infoVALUES('120706',N'软件设计',N'计算机机房',N'微机、投影仪',60);INSERTINTOclassroom_infoVALUES('120707',N'多媒体',N'计算机机房',N'微机、投影仪',60);INSERTINTOclassroom_infoVALUES('120708',N'',N'普通',N'白板、投影仪',120);USEstudentGOINSERTINTOdept_codeVALUES('01',N'计算机工程系');INSERTINTOdept_codeVALUES('02',N'管理工程系');INSERTINTOdept_codeVALUES('03',N'机电工程系');INSERTINTOdept_codeVALUES('04',N'食品工程系');INSERTINTOdept_codeVALUES('05',N'轻化工程系');INSERTINTOdept_codeVALUES('06',N'通信工程系');INSERTINTOdept_codeVALUES('07',N'外语工程系');USEstudentGOINSERTINTOlesson_infoVALUES('0401010101',N'计算机导论',N'考察',30,1.5);INSERTINTOlesson_infoVALUES('0401010102',N'Java程序设计',N'考试',60,3.5);INSERTINTOlesson_infoVALUES('0401010103',N'微型计算机原理',N'考试',60,3.5);INSERTINTOlesson_infoVALUES('0401010104',N'IT市场营销',N'考察',30,1.5);INSERTINTOlesson_infoVALUES('0401010105',N'网络互联设备与配置',N'考察',60,2.0);INSERTINTOlesson_infoVALUES('0401010106',N'多媒体技术',N'考察',60,3.0);USEstudentGOINSERTINTOspecialty_codeVALUES('040101',N'计算机应用技术');INSERTINTOspecialty_codeVALUES('040102',N'计算机网络技术');INSERTINTOspecialty_codeVALUES('040103',N'计算机控制技术');INSERTINTOspecialty_codeVALUES('040104',N'多媒体技术');INSERTINTOspecialty_codeVALUES('040105',N'计算机软件技术');INSERTINTOspecialty_codeVALUES('040106',N'计算机通信技术');INSERTINTOspecialty_codeVALUES('040107',N'计算机管理技术');USEstudentGOINSERTINTOstaffroom_infoVALUES('0101',N'计算机应用',N'专业',N'王二毛');INSERTINTOstaffroom_infoVALUES('0102',N'计算机网络',N'专业',N'李四冲');INSERTINTOstaffroom_infoVALUES('0103',N'计算机软件',N'专业',N'赵一生');INSERTINTOstaffroom_infoVALUES('0104',N'计算机管理',N'专业',N'汪三洋');USEstudentGOINSERTINTOstud_gradeVALUES('0401010811',N'张源','0401010102',90);INSERTINTOstud_gradeVALUES('0401020201',N'赵明','0401010105',89);INSERTINTOstud_gradeVALUES('0401030101',N'王刚','0401010103',87);INSERTINTOstud_gradeVALUES('0401050201',N'陈红','0401010101',91);INSERTINTOstud_gradeVALUES('0401040112',N'孙强','0401010104',83);INSERTINTOstud_gradeVALUES('0401020203',N'李伟','0401010106',86);INSERTINTOstud_gradeVALUES('0401010634',N'钱昆','0401010106',78);INSERTINTOstud_gradeVALUES('0401030213',N'郑芳','0401010106',95);INSERTINTOstud_gradeVALUES('0401010102',N'袁飞','0401010106',95);INSERTINTOstud_gradeVALUES('0401040123',N'孔荣','0401010106',83);INSERTINTOstud_gradeVALUES('0401050127',N'张军','0401010106',84);USEstudentGOINSERTINTOteach_scheduleVALUES('0401010101','08-30-2004','15','120703','01','010104');INSERTINTOteach_scheduleVALUES('0401010102','08-30-2004','15','120704','01','010101');INSERTINTOteach_scheduleVALUES('0401010103','08-30-2004','13','120705','01','010106');INSERTINTOteach_scheduleVALUES('0401010104','08-30-2004','10','120706','01','010105');INSERTINTOteach_scheduleVALUES('0401010105','08-30-2004','19','120707','01','010102');INSERTINTOteach_scheduleVALUES('0401010106','08-30-2004','14','120708','01','010103');-(6).修改数据-(6).1updatestud_gradesetgrade=grade+grade*0.1wherecourse_id='0401010101'-(6).2updatestud_gradesetgrade=nullwheregrade

    注意事项

    本文(SQL第四章课后习题答案.docx)为本站会员(安***)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开