当前位置:Gxlcms > mysql > mssqlserverCREATEDATABASE创建数据库代码

mssqlserverCREATEDATABASE创建数据库代码

时间:2021-07-01 10:21:17 帮助过:28人阅读

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 ] [ [ ,...n ]
[ , [ ,...n ] ]
[ log on { [ ,...n ] } ] }
]
[ collate collation_name ]
[ with ]
]
[;]

to attach a database
create database database_name
on [ ,...n ]
for { attach [ with ]
| attach_rebuild_log }
[;]

::=
{
(
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_name [ contains filestream ] [ default ]
[ ,...n ]
}

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

create a database snahot
create database database_snapshot_name
on
(
name = logical_file_name,
filename = 'os_file_name'
) [ ,...n ]
as snapshot of source_database_name
[;]

人气教程排行