注册 登录
编程论坛 SQL Server论坛

消息 142,级别 15,状态 2,第 0 行 约束 'TABLE' 的定义中有语法错误。

cjmf322 发布于 2022-07-30 16:49, 1127 次点击
use student
   create table student
   ( sno char(8)   not null primary key ,
     sname char (10) not null ,
     gender char(2) null ,default '男' ,check (gender='男'
   or gender='女'),
   sbirth date,
   major char (30),
   credit int check ( credit>=0 and credit<120),
   remark varchar (200)
   
   
   )
2 回复
#2
cjmf3222022-07-30 16:51
gender char(2) null ,default '男' ,check (gender='男'
改为
gender char(2) null default '男' ,check (gender='男'
#3
mywisdom882022-08-02 08:42
create table student
( sno char(8) not null primary key ,
  sname char (10) not null ,
  gender char(2) null default '男' ,check (gender in('男','女')),
  sbirth date,
  major char (30),
  credit int check ( credit>=0 and credit<120),
  remark varchar (200)
)
1