--创建数据库
create database mydb
on primary
(
name=mydbdata,
Filename=‘E:\mydb_data.mdf‘,
size=5mb,
maxsize=6mb,
Filegrowth=1mb
)
log on
(
name=mydblog,
filename=‘E:\mydb_log.ndf‘,
size=2mb,
maxsize=5mb,
filegrowth=1%
)
--删除数据库
use master
go
if exists(select * from sysdatabases where name=‘mydb‘)
drop database mydb
go
--添加次数据库
alter database mydb
add log file
(
name=mydalog2,
filename=‘E:\mydb_log2.ndf‘,
size=1mb,
maxsize=5mb,
filegrowth=1%
)
--删除次数据库
alter database mydb
remove file mydalog2
--修改数据库名字
alter database mydb
modify name=youdb
--备份数据库 --name=‘mydbbackup‘是备注随便写
backup database mydb to disk=‘E:\mydbbackup.bak‘ with format, name=‘mydbbackup‘
--恢复数据库
USE master
GO
restore database mydb from disk=‘E:\mydbbackup.bak‘
GO
时间: 2024-10-25 17:46:47