My MySQL version is 5. The following SQL exercises are the prerequisite scripting code.
--Student (s#,sname,sage,ssex) Student table-Course (c#,cname,t#) Schedule-SC (s#,c#,score) Table-Teacher (t#,tname) Teacher table CREATE table Student (SID Int (4) NOT null primary key auto_increment, sname char () is not NULL, Sage Int (3) is not NULL, Ssex int ( 1) NOT NULL for default ' 1 '), CREATE TABLE course (CID int (4) NOT null primary key auto_increment, CNAME char (a) NOT NULL, Tid int (4) not NULL), the CREATE TABLE SC (SID int (4) NOT NULL, CID int (4) is not NULL, score int (3) is not null); CREATE TABLE Teacher (tid int (4) NOT null primary key auto_increment, Tname char (a) not null); INSERT into student values (1, ' Tom ', 25, 1), (2, ' Joan ', 19,0), (3, ' Wang ', 41,1), (4, ' Lucy ', 52,0), (5, ' Lili ', 61,1), insert into teacher values (1, ' liming '), (2, ' Wa Ngshan '), (3, ' Zhangheng '), (4, ' Hushi '), insert into course values (1, ' Java ', 2), (2, ' think ', 3), (3, ' math ', 1), (4, ' Chinese ', 1), (5, ' High Math ', 2); Insert to SC values (1,1,24), (1,2,60), (1,3,70), (1,4,90), (1,5,99); INSERT into SC values (2,1,60 ), (2,2,80), (2,3,60), (2,4,91), (2,5,89) INSERT into SC values (3,1,66), (3,2,78), (3,3,90), (3,4,78), (3,5,90), insert into SC values (4,1,80), (4,2,34), ( 4,3,81), (4,4,56), (4,5,90); INSERT into SC values (5,1,99), (5,2,32), (5,3,45), (5,4,12), (5,5,76);
2016030207-sql50 Exercises (script)