当前位置:首页 > SQL2012实验报告 - 图文
Ssex char(2), Sage smallint, Sdept char(20) );
a、 首先打开SSMS,然后点击连接,点击视图选中对象资源管理器打开,选中数据库点开,选中TestDB双击打开选中表dbo.Student,左键单击左上方工具栏中的新建查询(N),如下图所示:
b、 在出现的新建查询对话框中输入: creat TABLE Student1
(Sno char(9) primary key, Sname char(20) unique not null, Ssex char(2), Sage smallint, Sdept char(20) );
执行后如图所示:
3. 要求Student表中的Ssex属性的取值只允许取“男”或“女”
creat TABLE Student (Sno char(9) primary key, Sname char(8) not null,
Ssex char(2) check (Ssex in (‘男’,’女’)), Sage smallint, Sdept char(20)
);
a、首先打开SSMS,然后点击连接,点击视图选中对象资源管理器打开,选中数据库点开,选中TestDB双击打开选中表双击选择dbo.Student,右键单击设计(G),出现dbo.Student对话框,右键单击列名Ssex右侧选择CHECK约束(O)。如下图所示:
共分享92篇相关文档