mssql server CREATE DATABASE创建数据库代码
mssql server create database创建数据库教程代码
/*
if db_id('test') is not null drop database test
go
create database test
on 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_as
with
db_chaining off
,trustworthy off
语法
create database database_name
[ on
{ [ primary ] [ <filespec> [ ,...n ]
[ , <filegroup> [ ,...n ] ]
[ log on { <filespec> [ ,...n ] } ] }
]
[ collate collation_name ]
[ with <external_access_option> ]
]
[;]
to attach a database
create database database_name
on <filespec> [ ,...n ]
for { attach [ with <service_broker_option> ]
| attach_rebuild_log }
[;]
<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 ]
}
<filegroup> ::=
{
filegroup filegroup_name [ contains filestream ] [ default ]
<filespec> [ ,...n ]
}
<external_access_option> ::=
{
[ db_chaining { on | off } ]
[ , trustworthy { on | off } ]
}
<service_broker_option> ::=
{
enable_broker
| new_broker
| error_broker_conversations
}
create a database snaps教程hot
create database database_snapshot_name
on
(
name = logical_file_name,
filename = 'os_file_name'
) [ ,...n ]
as snapshot of source_database_name
[;]
补充:数据库,Mssql