course(Аcno char(4) primary key ,? cname varchar(50) unique not null, Аccredit smallint redit>0));?CREATE TABLE SC(? sno int references student(sno),? cno char(4) references o),? grade smallint CHECK (grade between 0 and 100));РCREATE TABLE sc(? sno int references student ON UPDATE CASCADE ON DELETE CASCADE, ? //希望在学生记录改变时自动改变分数记录,在删除学生时,级联删除分数记录。? cno char(4) references course ON UPDATE CASCADE, ? //希望在改变课程时自动改变分数记录表里关于课程的引用,但是不希望删除课程时级联删除分数。? grade smallint CHECK (grade between 0 and 100) );Р约束的创建、查看、删除?●增加主键约束?基本语法:?ALTER TABLE 表名 ADD CONSTRAINT 主键约束名 PRIMARY KEY [CLUSERED|NONCLUSTERED]? (列名1【,列名2,…列名n)】Р例1:创建一个表SC,o字段定义为主键,主键名为:PK_Student1。?方法一:?CREATE TABLE SC ?(sno int NOT NULL, ? cno char(4) NOT NULL, ? grade int NULL,? CONSTRANT PK_Student1 PRIMARY KEY (o))?注意:? 如果不指定主键名,系统将自动分配名称。