2015.4.2SQL simple statement, 2015.4.2sql statement

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.