没有合适的资源?快使用搜索试试~ 我知道了~
mysql数据库实验答案.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 126 浏览量
2022-07-02
01:45:38
上传
评论
收藏 1.48MB DOCX 举报
温馨提示
试读
39页
mysql数据库实验答案.docxmysql数据库实验答案.docxmysql数据库实验答案.docxmysql数据库实验答案.docxmysql数据库实验答案.docxmysql数据库实验答案.docxmysql数据库实验答案.docxmysql数据库实验答案.docxmysql数据库实验答案.docx
资源推荐
资源详情
资源评论
SQL 查询语句大全
实验一 创建、修改数据库和表结构
1、用 create 建立教学数据库的五个基本表:
学生表(学号,姓名,性别,年龄),student((Sno, sname, ssex,sage) ;
(1)
(2)课程表(课程号,课程名,学分),Course (Cno, Cname, credit) ;
(3)选课表(学号,课程号,成绩),SC (Sno,, Cno, grade ) ;
(4) 教师表(教师号,姓名,性别,出生年月,系部,职称,地址),
T(Tno,Tname,ssex,birthday,dept,title,address) ;
(5) 工资表(教师号,基本工资,职务工资,合计),Salary(Tno,jbgz,zwgz,hj);
Create Database Student default character set utf8 default COLLATE utf8_bin;
Use Student;
Create Table Student(
SNo char(20) primary key,
SName char(20) ,
页脚内容 1
SQL 查询语句大全
SSex char(4) default '男',
SAge int
) ENGINE=InnoDB;
Create Table Course(
CNo char(20) primary key,
CName char(20) NOT NULL,
CRedit float
) ENGINE=InnoDB;
Create Table SC(
SNo char(20) NOT NULL,
CNo char(20) NOT NULL,
Grade float,
Primary Key(SNo, CNo),
页脚内容 2
SQL 查询语句大全
Foreign Key(SNo) References Student(SNo) On Delete Cascade,
Foreign Key(CNo) References Course(CNo)
) ENGINE=InnoDB;
Create Table T(
TNo char(20) Primary Key,
TName char(20) NOT NULL,
TSexchar(4) default '男',
birthday DateTime,
deptchar(20),
title char(20),
address char(20)
) ENGINE=InnoDB;
Create Table Salary(
页脚内容 3
SQL 查询语句大全
TNo char(20) NOT NULL,
jbgz float,
zwgz float,
hj float,
Foreign Key(TNo) References T(TNo) On Delete Cascade
) ENGINE=InnoDB;
2、用 alter 修改基本表
(1)在已存在的学生表 student 中增加一个 sdept(系)的新的属性列;
alter table Student add Dept char(20);
(2)将学生表 student 中 sname 属性列的数据类型修改为变长字符串 varchar(10)。
alter able Student modify colum sname varchar(10)
3、建立一个临时表,然后将其删除
Create Table temp (
页脚内容 4
SQL 查询语句大全
ANo char(20) NOT NULL,B float, C char(10) )
Drop table temp
实验二 建立与删除索引
1、用 create index 在学生表 student 的学号 sno 上建立聚簇索引。
Create Clustered Index SNo_Index On Student(SNo);
2、在学生表 student 中,为姓名 sname 建立非聚簇索引。
Create Index SName_Index On Student(SName);
3、在课程表的课程号 Cno 上建立唯一索引。
Create Unique Index CNo_Index On Course(CNo);
4、在选课表的学号 sno、成绩 Grade 上建立复合索引,要求学号为升序,学号相同时成绩为
降序。
Create Index SCNo_Index On SC(SNo ASC, Grade DESC);
5、用 drop 删除学生表 student 的索引。
页脚内容 5
剩余38页未读,继续阅读
资源评论
不吃鸳鸯锅
- 粉丝: 8225
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功