当前位置:   article > 正文

【SQL】数据库实验总结

数据库实验总结

在这里插入图片描述

--是单行注释的意思

多行注释是
/*
	...
*/

create database firstdb //创建数据库
sp_helpdb 'firstdb' //显示该数据库
sp_renamedb 'a','b' //重命名
drop database thisdb //删除数据库thisdb

1、在查询分析器中创建一个数据库,要求如下:
(1)数据库名称 Test2。
(2)主要数据文件:逻辑文件名为Test2_data1,物理文件名为Test2_data1.mdf,初始容量为10MB,最大容量为100MB,增幅为10MB。
(3)次要数据文件:逻辑文件名为Test2_data2,物理文件名为Test2_data2.ndf,初始容量为10MB,最大容量为10MB,增幅为15%。
(4)事务日志文件:逻辑文件名为Test2_log1,物理文件名为Test2_log1.ldf,初始容量为10MB,最大容量为50MB,增幅为20MB。

create database Test2
on primary (name=Test2_data1,  
filename='d:\sqlex\Test2_data1.mdf',   
size=10,               
maxsize=100,                 
filegrowth=10),     
(name=Test2_data2,   
filename='d:\sqlex\Test2_data2.ndf',
size=10,
maxsize=10,                 
filegrowth=15%
)

log on(name=Test2_log1,    
filename='d:\sqlex\Test2_log1.ldf',
size=10,
maxsize=50,
filegrowth=20)

2、在查询分析器中按照下列要求修改上文题中创建的数据库test2
(1)主要数据文件的容量为50MB,最大容量为200MB,增幅为20MB。
(2)次要数据文件的容量为50MB,最大容量为300MB,增幅为20MB。
(3)事务日志文件的容量为30MB,最大容量为100MB,增幅为10%alter database test2
modify file (name=Test2_data1,  
size=50,
maxsize=200,
filegrowth=20)

alter database test2
modify file (name=Test2_data2,  
size=50,
maxsize=300)

alter database test2
modify file (name=Test2_data2,  
filegrowth=20)

alter database test2
modify file(name=Test2_log1,  
size=30,
maxsize=100,
filegrowth=10%)

3、数据库更名:把test1数据库更名为new_test1
sp_renamedb test1, new_test1

4、在查询分析器中删除test2数据库。
drop database  test2

5、删除计算机系选修成绩不及格的学生的选修记录。
delete score
from score,student
where student.student_id =score.student_id and score.grade<60

6、查询选修了3门以上课程的学生姓名学号
select student.student_id,student.student_name,count(score.course_id) as 选课数量
from student,score
where student.student_id=score.student_id
group by  student.student_id,student.student_name
having count(score.course_id)>3
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/970590
推荐阅读
相关标签
  

闽ICP备14008679号