mssql server CREATE DATABASE创造数据库代码

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[;]

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

一,用T-SQL创造数据库
简单的:
数据名:Sales
数据库主文件路线全名:d:\dbfiles\sales_dat.mdf
日志文件路线全名:d:\dbfiles\sales_log.ldf
当心,目录必定要留存,不然会成立战败。
create database Sales
on primary
(
 name=’salesdb’,  –文件逻辑名
 filename=’d:\dbfiles\sales_dat.mdf’, –文件磁盘文件路线全称
 size=5, –起先化大小
 maxsize=15, –最大值
 filegrowth=1 –增量
)
log on
(
  name=’saleslog’,
  file=’d:\dbfiles\sales_log.ldf’,
  size=5,
  maxsize=15,
  filegrowth=1
)
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 SEEscortVE奇骏 2007 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

创设多个名叫TEST2的数据库,它有2个数据文件,此中主数据文件为100MB,最大尺寸为200MB,按20MB增进;1个帮忙数据文件为20MB,最大尺寸不限,按一成巩固;有2个日志文件,大小均为50MB,最大尺寸均为100MB,按10MB拉长。

在现存数据库底蕴上增多新日志文件
alter database dbname
add log file
(
 name=” , file=” , size=,….
)

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

四,用T-SQL纠正数据库的组织 在现存数据库基本功上增加新数据库文件
alter database dbname
add file
(
  name=”,file=”,size=,….
)
go

发表评论

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