1. Create a "student" table Student
CREATE TABLE Student_muanfeng (
Sno Char (4) primary key (primary key),
Sname char unique (for constraint),
Ssex char (2) null check (Sex in (' M ', ' F ')),
Sage smallint null check (AGE>18 and age<25),
Sdept Char (20)
);
2. Create a "course" table course
Create Table Course (
Cno char (4) Primary key,
Cname Char (40),
Credit smallint null check (credit>0 and credit<10)
);
)
3, set up students ' timetable SC
Create Table SC
Sno Char (4) is not NULL, CNO char (4) is not NULL primary key (SNO,CNO),
Grade smallint null check (grade>0 and grade <100))
ALTER TABLE SC add constraint Fk_sno foreign key (SNO) references Student (SNO);
ALTER TABLE SC add constraint fk_cno foreign key (CNO) references Course (CNO);
2.Create Table SC (
Sno char (4),
Cno Char (4),
Primary Key (SNO,CNO),
Frimary key (Sno) reference student (Sno),
Frimary key (Cno) reference Course (Cno),
);
Insert data:
Insert into table name (condition) value (corresponding value)
2015/4/2 SQL database to create a Table table association