求使用sql语句创建和删除数据库的代码
发布网友
发布时间:2022-04-22 04:28
我来回答
共1个回答
热心网友
时间:2022-04-07 19:33
1、使用create
database创建数据库test
create
database
test
on
primary
(
name
=
'test',
filename='c:\program
files\microsoft
sql
server\mssql\data\test.mdf',
size=10240kb,
maxsize
=
unlimited,
filegrowth
=
10%)
log
on
(
name='test_log',
filename='c:\program
files\microsoft
sql
server\mssql\data\test_log.ldf',
size=1024kb,
maxsize
=
5120kb,
filegrowth
=
1024kb
)
go
2.
使用alter
database语句修改数据库
例4-3 将两个数据文件和一个事务日志文件添加到test数据库中。
程序清单如下:
alter
database
test
add
file
(name
=
test1,
filename='c:\program
files\microsoft
sql
server\mssql\data\test1.ndf',
size
=
5mb,
maxsize
=
100mb,
filegrowth
=
5mb),
(name
=
test2,
filename='c:\program
files\microsoft
sql
server\mssql\data\test2.ndf',
size
=
3mb,
maxsize
=
10mb,
filegrowth
=
1mb)
go
alter
database
test
add
log
file
(
name
=
testlog1,
filename='c:\program
files\microsoft
sql
server\mssql\data\testlog1.ldf',
size
=
5mb,
maxsize
=
100mb,
filegrowth
=
5mb)
go
3、重命名test为demo
sp_renamedb
'test','demo'
4、删除数据库
drop
database
demo