SQL考试(推荐).doc

  1. 1、本文档共7页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
SQL考试(推荐)

1.创建数据库: 操作1.1:创建一个test数据库,其主数据文件逻辑名test_data,物理文件名test_data.mdf,初始大小10MB,最大尺寸为无限大,增长速度1MB;数据库日志文件逻辑名称为test_log,物理文件名为test_log.ldf,初始大小为1MB,最大尺寸为5MB,增长速度为10%。 参考答案: create database Test ON primary (name = test_data, filename = d:\test\test_data.mdf, size = 5MB, maxsize = unlimited, filegrowth = 1MB) LOG ON (name = test_log, filename = d:\test\test_log.ldf, size = 1MB, maxsize = 5MB, filegrowth = 10%) GO 3.删除数据库: T-SQL语句删除数据库test 参考答案: drop database Test 1.创建表: 操作2.1:创建学生表: 表名:student 说明:学生基本信息表 属性列 数据类型 长度 空值 列约束 说明 st_id nVarChar 9 Not Null PK 学生学号 st_nm nVarChar 8 Not Null 学生姓名 st_sex nVarChar 2 Null 学生性别 st_birth datetime Null 出生日期 st_score int Null 成绩 st_ datetime Null 入学日期 st_from nChar 20 Null 学生来源 st_dpid nVarChar 2 Null 所在系编号 st_mnt tinyint Null 学生职务 USE test GO CREATE TABLE student (st_id nVarChar(9) primary key NOT NULL , st_nm nVarChar(8) NOT NULL , st_sex nVarChar(2) NULL , st_birth datetime NULL , st_score int NULL , st_date datetime NULL , st_ from nVarChar(20) NULL , st_dpid nVarChar(2) NULL , st_ mnt tinyint NULL) GO 操作2.2:创建课程信息表表名:couse 说明:课程信息表 属性列 数据类型 长度 空值 列约束 说明 cs_id nVarChar 4 Not Null PK 课程编号 cs_nm nVarChar 20 Not Null 课程名称 cs_tm int Null 课程学时 cs_sc int Null 课程学分 USE test GO CREATE TABLE couse (cs_id nVarChar(4) primary key NOT NULL , cs_nm nVarChar(20) NOT NULL , cs_tm int NULL , cs_sc int NULL) GO 操作2.3:创建选课表表名:slt_couse 说明:选课表 属性列 数据类型 长度 空值 列约束 说明 cs_id nVarChar 4 Not Null FK 课程编号 st_id nVarChar 9 Not Null FK 学生编号 score int Null 课程成绩 sltdate datetime Null 选课 参考答案: USE test GO CREATE TABLE couse (cs_id nVarChar(4) NOT NULL , st_id nVarChar(9) NOT NULL , score int NULL , sltdate datetime NULL) GO 操作2.4:创建院系信息表表名:dept 说明:院系信息表 属性列 数据类型 长度 空值 列约束 说明 dp_id nVarChar 2 Not Null 系编号 dp_nm nVarChar 20 Not Null 院系名称 dp_drt nVarChar 8 Null 院系主任 dt_tel nVarChar Null 联系电话 USE test GO CREATE TABLE dept (dp_id nVarChar(2)

文档评论(0)

mv2323 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档