USE would
GO
The CREATE TABLE student
(
Sno char (7) PRIMARY KEY,
Sname nvarchar (8) NOT NULL,
Ssex nchar (1) the NOT NULL CONSTRAINT chk_sex CHECK (ssex='male' or ssex='female'),
Sage varchar (2) the NULL CONSTRAINT chk_age CHECK (sage between 15 AND 30),
En_time datetime NULL,
Specialty varchar (20) NULL,
Grade char (10) NULL
)
INSERT into student VALUES (' 1302001 ', 'ms cheung' and 'male', '20', '2013-09-06', 'computer', 'level 13)
INSERT into student VALUES (' 1302005 ', '.my name's zhengli from ', 'female' and '21', '2013-09-06', 'network', 'level 13);
INSERT into student VALUES (' 1401001 ', 'Zhu Yihong', 'female' and '19', '2014-09-09', 'computer', '14')
INSERT into student VALUES (' 1401003 ', 'shen' and 'female' and '20', '2014-09-05', 'electronic', '14');
INSERT into student VALUES (' 1403001 ', 'li-hong zhao', 'female' and '20', '2013-09-06', 'network', '14')
INSERT into student VALUES (' 1404001 ', 'hong-wei li', 'male', 'the', '2013-09-06', 'communications',' 14 ')
INSERT into student VALUES (' 1404006 ', 'Liu Jingpeng' and 'male', 'the', '2013-09-06', 'communications',' 14 ')
INSERT into student VALUES (' 1501001 ', 'zhang ling', 'female' and '19', '2013-09-06', 'electronic', '15')
INSERT into student VALUES (' 1501008 ', 'zhang ling', 'female' and '18', '2013-09-06', 'electronic', '15')
INSERT into student VALUES (' 1502003 ', 'b' and 'male', 'the', '2013-09-06', 'electronic', '15')
INSERT into student VALUES (' 1502005 ', 'liu mei', 'female' and '19', '2013-09-06', 'computer', '15')
INSERT into student VALUES (' 1503001 ', 'b' and 'male', '18', '2013-09-06', 'network', '15')
USE would
GO
The CREATE TABLE course
(
Cno char (4) PRIMARY KEY,
Cname nvarchar (20) NOT NULL,
Classhour tinyint,
Credit tinyint
)
INSERT into course VALUES (' C001 ', 'c + + language', '3', '4')
INSERT into course VALUES (' C004 ', 'operating system', '3', '3')
INSERT into course VALUES (' E002 ', 'technology', '5', '5')
INSERT into course VALUES (' R005 ', 'software engineering', '3', '3')
INSERT into course VALUES (' X003 ', 'signal principle', '4', '3')
USE would
GO
The CREATE TABLE sc
(
Sno char (7) NOT NULL,
Cno char (4) NOT NULL,
Score tinyint null CONSTRAINT chk_score CHECK (score between 0 AND 100),
PRIMARY KEY (sno, cno),
FOREIGN KEY REFERENCES (sno) student (sno),
FOREIGN KEY REFERENCES (cno) course (cno)
)
INSERT into sc VALUES (' 1302001 ', 'C001', '100')
INSERT into sc VALUES (' 1302001 ', 'C004', '81')
INSERT into sc VALUES (' 1302001 ', 'X003', '85')
INSERT into sc VALUES (' 1302005 ', 'C001', '78')
INSERT into sc VALUES (' 1302005 ', 'C004', '97')
INSERT into sc VALUES (' 1401003 ', 'C001', '72')
INSERT into sc VALUES (' 1401003 ', 'E002', '73')
INSERT into sc VALUES (' 1403001 ', 'C001', '85')
INSERT into sc VALUES (' 1404001 ', 'E002', '76')
INSERT into sc VALUES (' 1501001 ', 'X003', 'NULL')
INSERT into sc VALUES (' 1501008 ', 'X003', 'NULL')
CodePudding user response:
Don't quoteINSERT into sc VALUES (' 1501008 ', 'X003, NULL)