这就是说明你写的语句没问题,此句实现插入一条name为a kecheng为d fenshu为d 的数据
说明你插入的数据成功...
CREATE TABLE Student
(
Sno char(7) PRIMARY KEY ,
Sname nchar(5) NOT NULL ,
Sex nchar(1) DEFAULT '男' ,
Sage tinyint check( Sage>=15 ANd Sage <=45),
Sdept nvarchar(20) ---可变长度的统一编码nverchar
)
GO
INSERT INTO Student VALUES ('1','李明','男',20,N'计算机系')
INSERT INTO Student VALUES ('2','张然','女',19,N'经管系' )
INSERT INTO Student VALUES ('3','许晴','女',18,N'电子系')
CREATE TABLE Course
(
Cno char(7) PRIMARY KEY ,
Cname nvarchar(20) not null ,
Credit numeric(3,1) check(credit>=0) --numeric(p,,s) p 为精度,是为小数位个数
)
INSERT INTO Course VALUES('1', 'SQL Server',4)
INSERT INTO Course VALUES('2' ,'VB',3)
INSERT INTO Course VALUES('3','专业英语',2)
CREATE TABLE SC
(
Sno char(7) not null ,
Cno char(7) not null ,
Grade tinyint ,
PRIMARY KEY (Sno, Cno), --定义主码约束
FOREIGN KEY (Sno) REFERENCES Student(Sno) , --定义外码约束并关联student
FOREIGN KEY (Cno) REFERENCES Course(Cno)
)
INSERT INTO SC VALUES ('1','1',90)
INSERT INTO SC VALUES ('2','2',76)
INSERT INTO SC VALUES ('2','1',85)
INSERT INTO SC VALUES ('3','3',70)
Go
编程是一种快乐,享受代码带给我的乐趣!!!