打開指令 mysql -h localhost -P 3306 -u root -p
show databases;
use student;
set names gbk;
create table student (sno char(9) primary key,
sname char(20) unique,
sex char(2),
sage smallint,
sdept char(20)
);
create table course(
cno char(4) primary key,
cname char(40) not null,
cpno char(4),
ccredit smallint,
foreign key(cpno) references course(cno)
);
create table sc (
sno char(9),
cno char(4),
grade smallint,
PRIMARY KEY (sno,cno),
foreign key(sno) references student(sno),
foreign key(cno) references course(cno)
);
Insert into student values('201215121','李勇','男',20,'CS'),('201215122','劉晨','女',19,'CS'),('201215123','王明','女',18,'MA'),('201215125','張立','男',19,'IS');
select * from stu;
insert into course values('2','數學',null,2),('6','數據處理',null,2),('4','作業系統','6',3),('7','PASCAL語言','6',4),('5','資料結構','7',4),('1','資料庫','5',4),('3','資訊系統','1',4);
insert into sc values('201215121','1',92),('201215121','2',85),('201215121','3',88),('201215122','2',90),('201215122','3',80);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/324144.html
標籤:其他
上一篇:合并幾個Word檔案,使用檔案名作為Heading1,并將標題降級(嵌入)。
下一篇:用Python隨機生成英文名
