create database

Creates a new database.

Syntax

Syntax for nonclustered environments:
create [inmemory] [temporary] database database_name
	[use database_name as template]
	[on {default | database_device} [= size] 
		[, database_device [= size]]...] 
	[log on database_device [= size] 
		[, database_device [= size]]...]
	[with {dbid = number, default_location = "pathname", override}]
		| [[,]durability = { no_recovery
			| at_shutdown
			| full} ]
		[, [no] async_init]
		[ [,] compression = {none | row | page}]
		[ [,] lob_compression = {compression_level | off}]
		[ [,] inrow_lob_length = value ] 		}...
	[for {load | proxy_update}]
    [ encrypt with key_name]
Syntax for cluster environments:
create [ [ global | system ] temporary ] database database_name 
	[ for instance instance_name ]
	[on {default | database_device} [= size] 
		[, database_device [= size]]...] 
	[log on database_device [= size] 
		[, database_device [= size]]...]
	[with {override | default_location = "pathname"}]
	[for {load | proxy_update}]

Parameters

Examples

Usage

See also sp_changedbowner, sp_diskdefault, sp_helpdb, sp_logdevice, sp_renamedb, sp_spaceused in Reference Manual: Procedures.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

The permission checks for create database differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must have create database privilege. If you are creating the sybsecurity database, you must have the manage auditing privilege.

Disabled

With granular permissions disabled, you must be system administrator or have create database privilege. If you are creating the sybsecurity database, you must be a system security officer.

Auditing

Values in event and extrainfo columns of sysaudits are:

InformationValues
Event

9

Audit option

create

Command or access audited

create database

Information in extrainfo
  • Roles – current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – NULL

  • Proxy information – original login name, if set proxy is in effect

Related reference
alter database
disk init
disk reinit
drop database
dump database
load database
online database