最后一步插入失败
CREATE TABLE student(
sno INT PRIMARY KEY,
sname VARCHAR(20) NOT NULL,
sage INT DEFAULT 18
);
CREATE TABLE course(
cno INT PRIMARY KEY,
cname VARCHAR(20) NOT NULL,
ccredit INT DEFAULT 2
);
CREATE TABLE sc(
sno INT,
cno INT,
marks DECIMAL(4,1),
PRIMARY KEY(sno,cno),
FOREIGN KEY (sno) REFERENCES student(sno),
FOREIGN KEY (cno) REFERENCES course(cno)
);
ALTER TABLE sc MODIFY marks INT;
ALTER TABLE student
ADD sgender CHAR(2),
ADD sdept CHAR(20),
ADD GPA DECIMAL(3,2);
ALTER TABLE course
ADD cpre INT,
ADD FOREIGN KEY(cpre) REFERENCES course(cno);
#为 student 表 在 sname 列上定义一个名为index_student_sname的普通索引;
CREATE INDEX index_student_sname ON student(sname);
#student 表使用四条 INSERT 语句插入四条数据;
INSERT INTO student(sno,sname,sgender,sage,sdept) VALUES (19111602,'王小珂','女',19,'信息系');
INSERT INTO student(sno,sname,sgender,sage,sdept) VALUES (19116103,'卞嘉欣','女',20,'信息系');
INSERT INTO student(sno,sname,sgender,sage,sdept) VALUES (19111604,'左眼陈','男',18,NULL);
INSERT INTO student(sno,sname,sgender,sage,sdept) VALUES (19111605,'田佳琪','女',19,'计算机系');
INSERT INTO course (cno,cname,ccredit) VALUES (1,'数据库原理',5),(2,'数学',4),(3,'操作系统',3),(4,'信息组织',4),(5,'C语言',3),(6,'数据结构',2);
UPDATE course
SET cpre=6
WHERE cno=1 OR cno=3;
UPDATE course
SET cpre=1
WHERE cno=4;
UPDATE course
SET cpre=5
WHERE cno=6;
UPDATE course
SET cpre=NULL
WHERE cno=2;
INSERT INTO sc (sno,cno,marks) VALUES (19116102,1,30),(19116102,3,87),(19116102,6,96),(19116102,1,69),(19116102,3,90);
```