SQL SERVER 2012 第五章 创建和修改数据表 の CREATE语句

CREATE <object type> <object name>

CREATE DATABASE <database name>

比较完整的语法列表: 日志文件和数据库文件不要放在一块磁盘上,争抢磁盘IO,还有危害安全性。

CREATE DATABASE <database name>
[ON [PRIMARY]
  ([NAME = <‘logical file name‘>,]
  FILENAME = <‘file name‘>
  [,SIZE = <size in kilobytes,megabytes,gigabytes,or terabytes>]
  [,MAXSIZE = <size in kilobytes,megabytes,gigabytes,or terabytes>]
  [,FILEGROWTH = <kilobytes,megabytes,gigabytes,or terabytes|percentage>])]
[LOG ON
  ([NAME = <‘logical file name‘>,]
  FILENAME = <‘file name‘>
  [,SIZE = <size in kilobytes,megabytes,gigabytes,or terabytes>]
  [,MAXSIZE = <size in kilobytes,megabytes,gigabytes,or terabytes>]
  [,FILEGROWTH = <kilobytes,megabytes,gigabytes,or terabytes|percentage>])]
  [CONTAINMENT = OFF|PARTIAL]
  [COLLATE <collation name>]
  [FOR ATTACH [WITH <service broker>] | FOR ATTCH_REBUILD_LOG | WITH DB_CHAINING ON| OFF| TRUSTWORTHY ON|OFF] ----需要实践
  [AS SNAPSHOT OF <source database name>]
[;]

实战:

CREATE DATABASE Accounting
ON
(
NAME = ‘Accounting‘,
FILENAME = ‘D:\AccountingData.mdf‘,
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5
)
LOG ON
(
NAME = ‘AccountingLog‘,
FILENAME = ‘D:\AccountingLog.ldf‘,
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB
)

sp_help

sp_helpdb

sp_helpdb ‘dbname‘

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。