javaWeb第一次作业

数据库作业16个题

现在有一教学管理系统,具体的关系模式如下:

Student (no, name, sex, birthday, class)

Teacher (no, name, sex, birthday, prof, depart)

Course (cno, cname, tno)

Score (no, cno, degree)

其中表中包含如下数据:

Course表:

 

Score表:

Student表:

 

Teacher表:

根据上面描述完成下面问题:

注意:注意保存脚本,尤其是DDL和DML,以便进行数据还原)

DDL

  1. 写出上述表的建表语句。
student表
create table student(
no int primary key,
name varchar(16),
sex char(6),
birthday varchar(32),
class int );
Teacher表
create table Teacher(
no int primary key auto_increment,
name varchar(16),
sex char(6),
birthday varchar(211),
prof varchar(21),
depart varchar(122));
course表
create table course(
cno int primary key auto_increment,
cname varchar(23),
tno int ));
score表
create table score(
no int primary key,
cno int ,
degree double(8,2));

命令:

DML

2,给出相应的INSERT语句来完成题中给出数据的插入。

    数据我放在我的C盘了    
       mysql> truncate table db1.teacher;
		Query OK, 0 rows affected (0.01 sec)

		mysql> select * from teacher;
		Empty set (0.01 sec)

		mysql> LOAD DATA  INFILE 'C:\db1_teacher.txt' INTO TABLE teacher;
		Query OK, 15 rows affected (0.01 sec)
      mysql> truncate table db1.score;
		Query OK, 0 rows affected (0.01 sec)

		mysql> select * from teacher;
		Empty set (0.01 sec)

		mysql> LOAD DATA  INFILE 'C:\db1_score.txt' INTO TABLE  score;
		Query OK, 15 rows affected (0.01 sec)
      mysql> truncate table db1.student;
		Query OK, 0 rows affected (0.01 sec)

		mysql> select * from student;
		Empty set (0.01 sec)

		mysql> LOAD DATA  INFILE 'C:\db1_teacher.txt' INTO TABLE student;
		Query OK, 15 rows affected (0.01 sec)
       mysql> truncate table db1.course;
		Query OK, 0 rows affected (0.01 sec)

		mysql> select * from course;
		Empty set (0.01 sec)

		mysql> LOAD DATA  INFILE 'C:\db1_teacher.txt' INTO TABLE course;
		Query OK, 15 rows affected (0.01 sec)

命令:

 

单表查询

3,以class降序输出student的所有记录(student表全部属性)

命令:

select * from student order by class desc;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值