在创建一个新的对象时,除了创建者、系统管理员、数据库所有者(如果创建的对象是数据库,那么数据库所有者就是创建者)以外,其他人都无法访问。这允许您在创建对象后,进行所需要的任何修改,之后才明确允许其他人访问您创建的对象。
还需要注意的是:只能使用CREATE语句在本地服务器上创建对象(添加特定的服务器名称是不起作用的)。
完整的语法列表:
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>])]
[ COLLATE <collation name> ]
[ FOR ATTACH [WITH <service broker>]| FOR ATTACH_REBUILD_LOG| WITH DB_CHAINING ON|OFF | TRUSTWORTHY ON|OFF]
[AS SNAPSHOT OF <source database name>]
[;]
以下是一个示例:
CREATE DATABASE Accounting
ON
(NAME = 'Accounting',
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AccountingData.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5)
LOG ON
(NAME = 'AccountingLog',
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AccountingLog.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB);
GO