2015.4.2SQL simple statement, 2015.4.2sql statement
1. create a student table create table student_masen (sno char (4) not null primarykey sname nchar (10) not null sex char (1) null check ('M', 'F ') age smallint null check (age> 15 and age <25 ))
2. create a course table create table course_masen (cno char (4) not null primarykey cname char (10) not null credit smallint null check (credit> 0 and credit <10 ))
3. create table S_C_masen (sno char (4) not null cnno char (4) not null primarykey (sno, cno) grade smallint check (grade> = 0 and grade <= 100) alter table s_C_masen add constraint fk_sno foreign key (sno) references student_masen (sno) alter table s_C_masen add constraint fk_cno foreign key (cno) references sudent_masen (cno)
1. query the names of students whose gender is not male select sname from student_masen where sex! = 'M'
2. select sname from student_masen where sex = 'M' and age> 20
3. Sort the course names in ascending order by course number to query the result set select * from course_masen order by cno desc, cname asc
4. in the S_C table, students whose student ID is S1 have taken several select count (cno) from S_C_masen where sno = 's1, I have deepened my understanding of creating database tables and continue to work hard!