当前位置: 代码迷 >> Sql Server >> 想请问一下用SQL语句在创建表中的in的用法
  详细解决方案

想请问一下用SQL语句在创建表中的in的用法

热度:35   发布时间:2016-04-27 13:47:04.0
想请教一下用SQL语句在创建表中的in的用法?
为什么下面出错
create table Student(
cStudentNo char(12) not null,
vStudentName varchar(8) not null,
iSage smallint check(iSage>=0 and iSage <=100),
nSgender nchar(2) check in('男','女'),
cClass char(10) ,
vDepartment varchar(20) default '计算机系',
primary key (cStudentNo),
)
修改后正确的
create table Student(
cStudentNo char(12) not null,
vStudentName varchar(8) not null,
iSage smallint check(iSage>=0 and iSage <=100),
nSgender nchar(2) check (nSgender='男' or nSgender='女'),
cClass char(10) ,
vDepartment varchar(20) default '计算机系',
primary key (cStudentNo),
)

希望各位高手解释一下,感激不尽!

------解决方案--------------------
SQL code
create table Student(cStudentNo char(12) not null,vStudentName varchar(8) not null,iSage smallint check(iSage>=0 and iSage <=100),nSgender nchar(2) check (nSgender in('男','女')),cClass char(10) ,vDepartment varchar(20) default '计算机系',primary key (cStudentNo),)
------解决方案--------------------
SQL code
create table Student(cStudentNo char(12) not null,vStudentName varchar(8) not null,iSage smallint check(iSage>=0 and iSage <=100),nSgender nchar(2) check (nSgender in('男','女')),cClass char(10) ,vDepartment varchar(20) default '计算机系',primary key (cStudentNo))
  相关解决方案