数据库实验要SQL语言编写的

数据库实验要SQL语言编写的,第1张

-- Create table

create table Student

(

S_No varchar2(20),

S_Name varchar2(20) not null,

S_Sex varchar2(2) default '男',

S_Birthday date

)

;

-- Add comments to the table

comment on table Student

is '学生';

-- Create/Recreate primary, unique and foreign key constraints

alter table Student

add constraint Pri_S_No primary key (S_NO);

-- Create table

create table Course

(

C_No varchar2(20),

C_Name varchar2(40),

Grade number(4,1)

)

;

-- Add comments to the table

comment on table Course

is '课程';

-- Add comments to the columns

comment on column CourseGrade

is '分数';

-- Create/Recreate primary, unique and foreign key constraints

alter table Course

add constraint Pri_C_No primary key (C_NO);

-- Create table

create table T_Course

(

S_no varchar2(20),

C_no varchar2(20),

Grade number(4,1)

)

;

-- Add comments to the table

comment on table T_Course

is 'take the course选课信息';

-- Add comments to the columns

comment on column T_CourseGrade

is '成绩';

-- Create/Recreate primary, unique and foreign key constraints

alter table MEAT_Course

add constraint For_S_No foreign key (S_NO)

references Student (S_No);

alter table MEAT_Course

add constraint For_C_No foreign key (C_NO)

references Course (C_No);

3:

-- Add/modify columns

alter table Student add S_Tel varchar2(20);

-- Add comments to the columns

comment on column Student S_Tel

is '电话';

4:

-- Add/modify columns

alter table Course modify C_Name CVARCHAR2(20);

5:

INSERT INTO Student (S_No, S_Name,S_Sex, S_Birthday ) VALUES ('A001','日月哥','女',to_date('20110515','yyyyMMdd'))

其他你自己来

6:

update Course set Grade =Grade +1

7:

-- Create/Recreate indexes

create unique index PK_oo on Student(S_Birthday order by desc);

8:

select sS_No, avg(tcGrade) from Student s,T_Course tc where sS_No=tcS_No group by sS_No

9:

delete T_Course tc where tcS_No='A000';

delete Student s where sS_No='A000';

思考题自己来,我用的orcal,这都不给分的话,爆你菊花啦

实验MySQL备份与恢复

一、实验内容:

1、 使用SQL语句导入和导出表数据

2、 使用客户端工具备份还原数据库

3、 使用日志文件恢复数据库

二、实验项目:学生成绩数据库

创建用于学生成绩管理数据库,数据库名为XSCJ中,XSCJ数据库中包括三个表:xs(学生基本情况表)、kc(课程信息表)、xs_cj(成绩表)。。

三、实验步骤:(要求使用语句完成)

1、 使用select into ……outfile导出xs表数据,导出文件名为xstxt,要求每行记录结束回车换行;

81e797c2c6b2bf39e8224ee671ce647epng

2、 使用create table like语句创建一个与xs表结构相同的表xs1,并使用load data将xstxt的数据完整的导入xs1表中,并查看xs1表;

ca530d320003432441251d6e51809ff6png

3、 使用select into ……outfile导出kc表数据,导出文件名为kc1txt,要求字段之间用逗号隔开,字符型字段值用双引号括起来,每行记录以“->”开头,每行结束回车换行;

da32788bbec152b932b960b76d9c008dpng

4、 使用create table like语句创建一个与kc表结构相同的表kc1,并使用load data将kc1txt的数据导入kc1表中,要求导入数据是忽略前面3条记录,只导入课程名、课程号、学分三列的数据;

ffd68720a4ed8428b61cd6d1d65bcd02png

5、 使用mysqldump备份xscj数据库中的xs表到文件xs2sql中;

9c7c64de9fa61ec43e5ac175e6945d7dpng

6、 使用mysqldump备份xscj数据库到文件xscj1sql中

0e5ace5913933fbf7c12a53f0bc99875png

7、 使用mysqldump备份xscj数据库和mysql数据库到文件twodatabasesql中;

380c089e0891b90861dacff3b50e7be8png

8、 使用mysqldump备份MySQL服务器中的所有数据库到文件allsql中;

a0b9d6cef91a0ad5c98985ff6b002a76png

9、 删除xs表,使用mysql命令将文件xs2sql中的数据恢复到xscj数据库中

fb9e600c30fd5809d45a84af98830ba5png

10、 删除xscj数据库中的所有表,使用mysql命令将文件xscj1sql中的数据恢复到xscj数据库中;

1d044046eb1957607aefe19f014f5c0cpng

11、 将xs表中的数据清空,使用mysqlimport命令将xstxt中的数据导入到xs表中。

9a000f99f8226008a6c1c8fc945f2a42png

四、实验报告要求

1、 实验报告格式要求

包括内容:标题、实验内容、实验步骤、实验中遇到的问题及解决方案

2、 实验报告内容要求

(1) 标题参看实验指导标题+“实验报告”,如“实验一 MySQL的安装与命令初步实验报告”;

(2) 实验内容与实验指导中相同;

(3) 实验步骤中将自己实验中的每个步骤的命令和 *** 作结果显示界面进行截图完善。

(4) 实验中遇到的问题及解决方案中如实地将自己的问题的解决过程记录出来。

3、 实验报告提交要求

每次实验课结束之后,每个人需要提交实验报告,实验报告命名为:学号姓名

以上就是关于数据库实验要SQL语言编写的全部的内容,包括:数据库实验要SQL语言编写的、mysql备份与恢复的实验报告在哪里、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9307304.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存