create a database snaps教程hotcreate database database_snapshot_name
on ( name = logical_file_name, filename = ‘os_file_name’ ) [ ,…n
] as snapshot of source_database_name[;]

五,用T-SQL删除数据库文件
drop database dbname

创造一个名字为TEST2的数据库,它有2个数据文件,个中主数据文件为100MB,最大尺寸为200MB,按20MB拉长;1个帮扶数据文件为20MB,最大尺寸不限,按10%增进;有2个日志文件,大小均为50MB,最大尺寸均为100MB,按10MB增加。

external_access_option ::={ [ db_chaining { on | off } ] [ ,
trustworthy { on | off } ]}service_broker_option ::={ enable_broker
| new_broker | error_broker_conversations}

复杂的:有四个次数据库文件和次日志文件的意况.
create database Sales
on primary
(
  name=’sales1′,
  filename=’d:\dbfiles\sales1_dat.mdf’,
  size=5,
  maxsize=10,
  filegrowth=1
),
(
  name=’sales2′,
  filename=’d:\dbfiles\sales2_dat.ndf’,
  size=5,
  maxsize=10,
  filegrowth=1
)
,
(
  name=’sales3′,
  filename=’d:\dbfiles\sales3_dat.ndf’,
  size=5,
  maxsize=10,
  filegrowth=1
)
log on
(
  name=’saleslog1′,
  file=’d:\dbfiles\sales1_log.ldf’,
  size=5,
  maxsize=15,
  filegrowth=1
)
,
(
  name=’saleslog2′,
  file=’d:\dbfiles\sales2_log.ldf’,
  size=5,
  maxsize=15,
  filegrowth=1
)

create database db_test2
on
(
    name=’test_data1′,
    filename=’D:\Program Files (x86)\Microsoft
Office\db_test2.mdf’,
    size=5MB,
    maxsize=50MB,
    filegrowth=10%
),
(
    name=’test_data2′,
    filename=’D:\Program Files (x86)\Microsoft
Office\db_test2.mdf’,
    size=5mb,
    maxsize=unlimited,
    filegrowth=10%
)
log on
(
    name=’test_log1′,
    filename=’D:\Program Files (x86)\Microsoft
Office\test_log1.ldf’,
    size=2mb,
    maxsize=5MB,
    filegrowth=1MB
),
(
    name=’test_llog2′,
    filename=’D:\Program Files (x86)\Microsoft
Office\test_log2.ldf’,
    size=50mb,
    maxsize=100mb,
    filegrowth=10mb
)
go

filespec ::= {( name = logical_file_name , filename = {
‘os_file_name’ | ‘filestream_path’ } [ , size = size [ kb | mb | gb
| tb ] ] [ , maxsize = { max_size [ kb | mb | gb | tb ] |
unlimited } ] [ , filegrowth = growth_increment [ kb | mb | gb | tb
| % ] ]) [ ,…n ]}

外加表明:
上述T-SQL在SQL SE奥迪Q3VE福睿斯 二零零七 EXPRESS测验通过。

 

mssql server create database成立数据库教程代码/*if db_id(‘test’) is
not null drop database testgocreate database teston primary
(name=test_dat_main1,filename=’d:databasetest_dat_main1.mdf’,size=3mb,maxsize=unlimited,filegrowth=5mb),(name=test_dat_main2,filename=’d:databasetest_dat_main2.mdf’,size=3mb,maxsize=unlimited,filegrowth=5mb),filegroup
test_dat_sub1 default
(name=test_dat_sub1,filename=’d:databasetest_dat_sub1.mdf’,size=2mb,maxsize=unlimited,filegrowth=5mb),(name=test_dat_sub2,filename=’d:databasetest_dat_sub2.mdf’,size=2mb,maxsize=unlimited,filegrowth=5mb),filegroup
test_dat_sub2
(name=test_dat_sub3,filename=’d:databasetest_dat_sub3.mdf’,size=2mb,maxsize=unlimited,filegrowth=5mb)log
on
(name=test_log1,filename=’d:databasetest_log1.ldf’,size=10mb,maxsize=unlimited,filegrowth=10mb),(name=test_log2,filename=’d:databasetest_log2.ldf’,size=10mb,maxsize=unlimited,filegrowth=10mb)collate
chinese_prc_ci_aswithdb_chaining off,trustworthy off

遗留难题:怎么着在移除文件此前,把数量移动到别的文件上去?

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注