create database selecttest character set utf8;
use selecttest;
1.學生表(student)
create table student(
sno varchar(20) primary key,
sname varchar(20) not null,
s*** varchar(10) not null,
sbirthday datetime,
class varchar(20)
)character set utf8;
2.教師表(teacher)
create table teacher(
tno varchar(20) primary key,
tname varchar(20) not null,
t*** varchar(20) not null,
tbirthday datetime,
prof varchar(20) not null,
depart varchar(20) not null
)character set utf8;
3.課程表(course)
create table course(
cno varchar(20) primary key,
cname varchar(20) not null,
tno varchar(20) not null,
foreign key(tno) references teacher(tno)
)character set utf8;
4.成績表(score)
create table score(
sno varchar(20) not null,
cno varchar(20) not null,
degree decimal,
foreign key(sno) references student(sno),
foreign key(cno) references course(cno),
primary key(sno,cno)
)character set utf8;
1.新增學生資訊
insert into student values('101','李華','男','1998-08-15','95001');
insert into student values('102','王怡','男','1997-08-25','95001');
insert into student values('103','劉健康','男','1997-04-18','95001');
insert into student values('201','田雨','女','1999-09-15','95002');
insert into student values('202','李亞吉','男','1995-07-14','95002');
insert into student values('104','馬佳','女','1997-04-16','95001');
insert into student values('105','劉浪','男','1997-04-12','95001');
insert into student values('203','曾建','男','1998-09-06','95002');
insert into student values('204','王麗雲','女','1998-07-14','95002');
insert into student values('106','盧玉石','女','1997-04-16','95001');
insert into student values('301','劉媛媛','女','1999-03-19','95003');
insert into student values('302','吳軍','男','1997-06-12','95003');
insert into student values('303','肖慶','男','1998-02-26','95003');
insert into student values('304','王一雲','女','1998-07-25','95003');
insert into student values('305','林風','女','1997-01-05','95003');
2.新增教師資訊
insert into teacher values('001','李成','男','1977-04-18','副教授','計算機系');
insert into teacher values('002','張旭','男','1989-09-15','講師','計算機系');
insert into teacher values('003','王萍','女','1975-07-14','副教授','電子工程系');
insert into teacher values('004','劉冰湖','女','1992-04-16','助教','電子工程系');
3.新增課程資訊
insert into course values('3-105','計算機導論','001');
insert into course values('3-155','作業系統','002');
insert into course values('4-256','高等數學','003');
insert into course values('4-879','模擬電路','004');
4.新增成績資訊
insert into score values('101','3-105','89');
insert into score values('102','3-155','78');
insert into score values('103','4-879','92');
insert into score values('104','4-256','67');
insert into score values('105','3-155','78');
insert into score values('106','3-105','88');
insert into score values('201','4-256','82');
insert into score values('202','3-155','78');
insert into score values('203','4-879','92');
insert into score values('204','3-105','74');
MySQL 建庫建表等簡單操作
檢視已有庫 show databases show databases show databases g 新建庫的操作 create database 庫名 create database et 檢視建庫資訊 show create database 庫名 show create database ...
mysql建立使用者表 mysql 建庫建表建使用者
1.建立資料庫 create database school 2.使用資料庫 use school 3.建立使用者 create user jame localhost identified by jame 4.授權使用者 注意這裡是用了 哦,可以自己講school也替換成 號 grant sele...
mysql登入,建庫,建表
cmd下 mysql u使用者名稱 p密碼 使用者名稱可以用root 密碼沒有可以不設 顯示資料庫 show databases 檢視當前使用的資料庫 select database 建立資料庫 create database 資料庫名 character set utf8 字符集 collate ...