创建数据库
create database testdb1 on( name=testdb1, filename='d: estdb1.mdf', size=10, maxsize=50, filegrowth=1 ) log on( name=testdb_log, filename='d: estdb_log.ldf', size=1, maxsize=unlimited, filegrowth=10% ) go
create database testdb1 on( name=testdb1, filename='d: estdb1.mdf', size=10, maxsize=50, filegrowth=1 ) log on( name=testdb1_log, filename='d: estdb1_log.ldf', size=1, maxsize=unlimited, filegrowth=10% ), ( name=testdb2_log, filename='d: estdb2_log.ldf', size=1, maxsize=unlimited, filegrowth=10% ) go
查看数据库信息
execute sp_helpdb testdb1
或 sp_helpdb
sp_helpdb testdb1 alter database testdb1 add file( name=testdb1ndf1, filename='d: estdb1ndf1.ndf', size=5mb, maxsize=10mb, filegrowth=6mb ) to filegroup mygroup alter database testdb1 add log file( name=testdb3_log, filename='d: estdb3.ldf', size=5mb, maxsize=10mb, filegrowth=10% ) alter database testdb1 modify file(name=testdb1,size=21mb) go alter database testdb1 modify file (name=testdb_log,size=21mb) alter database testdb1 add filegroup mygroup go sp_helpfilegroup go sp_helpdb testdb1 alter database testdb1 remove file testdb3_log
filegroup用法 http://blog.csdn.net/kevinsqlserver/article/details/8573312
设置数据库只可以读
属性→选项→状态→数据库只读 true
use test
go
alter database test set read_only -- read_write
go
--sp_dboption test, 'read only','false'
sp_helpdb test use test go alter database test set read_write go alter database test modify file(name=te,size=15mb) use test go dbcc shrinkfile(te,10) go
任务→收缩→数据库
选中数据库→重命名→要改数据库名字→回车
sp_renamedb 原数据库名,新数据库名
drop database test