SQL数据库操作基本语句

--创建数据库seajack
create database seajack
on primary
(name=seajack_data,
filename="e:/Data/seajack.mdf",
size=3,
maxsize=6,
filegrowth=15%
)
log on
(
name=seajack_log,
filename="e:/Data/seajack.ldf",
size=3,
maxsize=15,
filegrowth=1
)
--打开数据库seajack
use seajack
go
--改变数据库大小
ALTER DATABASE seajack
MODIFY FILE
(name='seajack_data',size=12)

--将数据库空间压缩至最小容量
DBCC SHRINKDATABASE('seajack')
--查看数据库
sp_helpdb 'seajack'
--设置只读状态
EXEC sp_dboption 'seajack','read only',true
--数据库改名
EXEC sp_dboption 'seajack','single user',true
EXEC sp_renamedb 'seajack','tanghailong'
EXEC sp_dboption 'tanghailong','single user',false
--删除数据库
use Northwind
DROP DATABASE tanghailong

你可能感兴趣的:(SQL)