Create Database and student table in SQL

Source: Internet
Author: User

Creation:

 
Create Database zxlcreate table student table (student ID char (12) primary key, name char (6) Not null, Gender char (2) Check (Gender in ('male ', 'Female '), Class char (15) Create Table student table (student ID char (12) References student table (student ID), course number char (2) references curriculum (course number ), score int default (30), primary key (student ID, course number) Create Table curriculum (course number char (2) primary key, course name char (20 ), credit int check (credits> = 1 and credits <= 5 ))

Operation:

 

Insert into student table values ('20170101', 'zhang XL ', 'male', 'document 201190609112') insert into student table values ('20160301', 'zhang **', 'Female ', 'Article 1111') insert into values table values ('20170901', '01', 201190609112) insert into values table values ('20170901', '02 ', 99) insert into values table values ('20170101', '03', 88) insert into curriculum values ('01', 'database system', 3) insert into curriculum values ('02', 'vb. net', 4) insert into curriculum values ('03', 'java', 4) Select * from student table select name, course name, score from student table, curriculum, student table where (student table. student ID = student table. student ID and course schedule. course number = Course table. course No.) order by score descselect AVG (score) average score, max (score) highest score, min (score) lowest score from score table where student no. = '123'

 

 

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.