问题
问答题
关于Student表:
列名 | 含义 | 数据类型 | 约束 |
Sno | 学号 | 普通编码定字串,长度为 | 主码 |
Sname | 姓名 | 普通编码定长字符串,长度为10 | 非空 |
Ssex | 性别 | 普通编码定长字符串,长度为2 | 取值范围为:(男女,) |
Sage | 年龄 | 微整型 | 大于等于14 |
Sdept | 所在系 | 普通编码不定长字符串,长度为20 |
①写出创建上述关系表的SQL语句。
②在SC表中添加一个新的修课类别列,列名为XKLB,类型为char(4)。
③在Student表上为Sname列建立一个非聚集索引,索引名为:NonCluIdx_Sname。
答案
参考答案:
解析:①创建Student表的SQL语句为: CREATE TABLE Student( Sno char(7)primary key, Sname char(10)not null, Ssex char(2)check(Ssex In(’男’,’女’)), Sage tinyint check(Sage>=14), Sdept varchar(20) ) ②Alter Table student add XKLB char(4) ③CREATE INDEX NonCluIdx_Sname on student(Sname)