日期:2014-05-18  浏览次数:20563 次

想请教一下用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))