Skip to content

Commit 3531b80

Browse files
20250427 add geozone, edit pass
Co-authored-by: Strahinja <[email protected]>
1 parent 25e94eb commit 3531b80

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

docs/t-sql/statements/create-database-transact-sql.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: "CREATE DATABASE (Transact-SQL)"
3-
description: Create database syntax for SQL Server, Azure SQL Database, Azure Synapse Analytics, and Analytics Platform System
3+
description: Create database syntax for SQL Server and all SQL Database Engine platforms.
44
author: markingmyname
55
ms.author: maghan
6-
ms.reviewer: wiassaf
7-
ms.date: 12/12/2024
6+
ms.reviewer: wiassaf, dnethi
7+
ms.date: 04/27/2025
88
ms.service: sql
99
ms.subservice: t-sql
1010
ms.topic: reference
@@ -35,7 +35,7 @@ helpviewer_keywords:
3535
- "attaching databases [SQL Server], CREATE DATABASE...FOR ATTACH"
3636
dev_langs:
3737
- "TSQL"
38-
monikerRange: ">=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-current||=azuresqldb-mi-current||=azure-sqldw-latest||>=aps-pdw-2016"
38+
monikerRange: ">=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-current || =azuresqldb-mi-current || =azure-sqldw-latest || >=aps-pdw-2016"
3939
---
4040

4141
# CREATE DATABASE
@@ -234,7 +234,7 @@ A windows-compatible directory name. This name should be unique among all the Da
234234

235235
<BR><BR>
236236

237-
The following options are allowable only when CONTAINMENT has been set to PARTIAL. If CONTAINMENT is set to NONE, errors will occur.
237+
The following options are allowable only when CONTAINMENT has been set to PARTIAL. If CONTAINMENT is set to NONE, errors occur.
238238

239239
#### DEFAULT_FULLTEXT_LANGUAGE = \<lcid> | \<language name> | \<language alias>
240240

@@ -299,7 +299,7 @@ When set to `ON`, it creates a ledger database, in which the integrity of all us
299299

300300
Specifies that the database is created by [attaching](../../relational-databases/databases/database-detach-and-attach-sql-server.md) an existing set of operating system files. There must be a \<filespec> entry that specifies the primary file. The only other \<filespec> entries required are those for any files that have a different path from when the database was first created or last attached. A \<filespec> entry must be specified for these files.
301301

302-
FOR ATTACH requires the following:
302+
FOR ATTACH requires:
303303

304304
- All data files (MDF and NDF) must be available.
305305
- If multiple log files exist, they must all be available.
@@ -309,9 +309,9 @@ If a read/write database has a single log file that is currently unavailable, an
309309
> [!NOTE]
310310
> A database created by a more recent version of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] cannot be attached in earlier versions.
311311
312-
In [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], any full-text files that are part of the database that is being attached will be attached with the database. To specify a new path of the full-text catalog, specify the new location without the full-text operating system file name. For more information, see the Examples section.
312+
In [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], any full-text files that are part of the database that is being attached will be attached with the database. To specify a new path of the full-text catalog, specify the new location without the full-text operating system file name. For more information, see [Examples](#examples).
313313

314-
Attaching a database that contains a FILESTREAM option of "Directory name", into a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance will prompt [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] to verify that the Database_Directory name is unique. If it is not, the `ATTACH` operation fails with the error, `FILESTREAM Database_Directory name is not unique in this SQL Server instance`. To avoid this error, the optional parameter, *directory_name*, should be passed in to this operation.
314+
Attaching a database that contains a FILESTREAM option of "Directory name" prompts [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] to verify that the `Database_Directory` name is unique. If it is not, the `ATTACH` operation fails with the error, `FILESTREAM Database_Directory name is not unique in this SQL Server instance`. To avoid this error, the optional parameter, *directory_name*, should be passed in to this operation.
315315

316316
FOR ATTACH cannot be specified on a database snapshot.
317317

@@ -365,7 +365,7 @@ FOR ATTACH_REBUILD_LOG requires the following conditions:
365365
- All data files (MDF and NDF) must be available.
366366

367367
> [!IMPORTANT]
368-
> This operation breaks the log backup chain. We recommend that a full database backup be performed after the operation is completed. For more information, see [BACKUP](../../t-sql/statements/backup-transact-sql.md).
368+
> This operation breaks the log backup chain. We recommend that you take a full database backup immediately after the operation is completed. For more information, see [BACKUP](../../t-sql/statements/backup-transact-sql.md).
369369
370370
Typically, FOR ATTACH_REBUILD_LOG is used when you copy a read/write database with a large log to another server where the copy will be used mostly, or only, for read operations, and therefore requires less log space than the original database.
371371

@@ -491,7 +491,7 @@ Is the name of the new database snapshot. Database snapshot names must be unique
491491

492492
#### ON ( NAME =_logical_file_name_, FILENAME ='_os_file_name_') [ ,... *n* ]
493493

494-
For creating a database snapshot, specifies a list of files in the source database. For the snapshot to work, all the data files must be specified individually. However, log files are not allowed for database snapshots. FILESTREAM filegroups are not supported by database snapshots. If a FILESTREAM data file is included in a CREATE DATABASE ON clause, the statement will fail and an error will be raised.
494+
For creating a database snapshot, specifies a list of files in the source database. For the snapshot to work, all the data files must be specified individually. However, log files are not allowed for database snapshots. FILESTREAM filegroups are not supported by database snapshots. If a FILESTREAM data file is included in a `CREATE DATABASE` `ON` clause, the statement fails and an error will be raised.
495495

496496
For descriptions of NAME and FILENAME and their values, see the descriptions of the equivalent \<filespec> values.
497497

@@ -739,7 +739,7 @@ GO
739739

740740
### E. Attach a database
741741

742-
The following example detaches the database `Archive` created in example D, and then attaches it by using the `FOR ATTACH` clause. `Archive` was defined to have multiple data and log files. However, because the location of the files has not changed since they were created, only the primary file has to be specified in the `FOR ATTACH` clause. Beginning with [!INCLUDE[ssVersion2005](../../includes/ssversion2005-md.md)], any full-text files that are part of the database that is being attached will be attached with the database.
742+
The following example detaches the database `Archive` created in example D, and then attaches it by using the `FOR ATTACH` clause. `Archive` was defined to have multiple data and log files. However, because the location of the files has not changed since they were created, only the primary file has to be specified in the `FOR ATTACH` clause. Beginning with [!INCLUDE[ssVersion2005](../../includes/ssversion2005-md.md)], any full-text files that are part of the database that is being attached are attached with the database.
743743

744744
```sql
745745
USE master;
@@ -1027,7 +1027,7 @@ CREATE DATABASE database_name
10271027
| 'HS_MOPRMS_n'
10281028
| { ELASTIC_POOL(name = <elastic_pool_name>) } })
10291029
]
1030-
[ WITH ( BACKUP_STORAGE_REDUNDANCY = { 'LOCAL' | 'ZONE' | 'GEO' } ) ]
1030+
[ WITH ( BACKUP_STORAGE_REDUNDANCY = { 'LOCAL' | 'ZONE' | 'GEO' | 'GEOZONE' } ) ]
10311031
[;]
10321032
```
10331033

@@ -1066,10 +1066,14 @@ By default, the metadata catalog for system object names is collated to *SQL_Lat
10661066
WITH CATALOG_COLLATION = DATABASE_DEFAULT
10671067
```
10681068

1069-
#### BACKUP_STORAGE_REDUNDANCY = {'LOCAL' | 'ZONE' | 'GEO'}
1069+
<a id="#backup_storage_redundancy--local--zone--geo"></a>
1070+
1071+
#### BACKUP_STORAGE_REDUNDANCY = {'LOCAL' | 'ZONE' | 'GEO' | 'GEOZONE'}
10701072

10711073
Specifies how the point-in-time restore and long-term retention backups for a database are replicated. Geo restore or ability to recover from regional outage is only available when database is created with `GEO` backup storage redundancy. Unless explicitly specified, databases created with T-SQL use geo-redundant backup storage.
10721074

1075+
Use `GEOZONE` for geo-zone redundant storage. Geo-zone redundant storage (GZRS) offers the highest level of protection against zonal outages as well as regional outages for any workload.
1076+
10731077
To enforce data residency when you're creating a database by using T-SQL, use `LOCAL` or `ZONE` as input to the BACKUP_STORAGE_REDUNDANCY parameter.
10741078

10751079
When creating a database as a copy of another database with `AS COPY OF`, specifying options is supported and should be wrapped in parentheses. For example, `WITH (BACKUP_STORAGE_REDUNDANCY = 'LOCAL');`.
@@ -1182,7 +1186,7 @@ To change the size, edition, or service objective values later, use [ALTER DATAB
11821186

11831187
Copying a database using the `CREATE DATABASE` statement is an asynchronous operation. Therefore, a connection to the [!INCLUDE[ssSDS](../../includes/sssds-md.md)] server is not needed for the full duration of the copy process. The `CREATE DATABASE` statement returns control to the user after the entry in `sys.databases` is created but before the database copy operation is complete. In other words, the `CREATE DATABASE` statement returns successfully when the database copy is still in progress.
11841188

1185-
- Monitoring the copy process on an [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)] server: Query the `percentage_complete` or `replication_state_desc` columns in the [dm_database_copies](../../relational-databases/system-dynamic-management-views/sys-dm-database-copies-azure-sql-database.md) or the `state` column in the **sys.databases** view. The [sys.dm_operation_status](../../relational-databases/system-dynamic-management-views/sys-dm-operation-status-azure-sql-database.md) view can be used as well as it returns the status of database operations including database copy.
1189+
- Monitoring the copy process on an [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)] server: Query the `percentage_complete` or `replication_state_desc` columns in the [dm_database_copies](../../relational-databases/system-dynamic-management-views/sys-dm-database-copies-azure-sql-database.md) or the `state` column in the `sys.databases` view. The [sys.dm_operation_status](../../relational-databases/system-dynamic-management-views/sys-dm-operation-status-azure-sql-database.md) view can be used as well as it returns the status of database operations including database copy.
11861190

11871191
At the time the copy process completes successfully, the destination database is transactionally consistent with the source database.
11881192

@@ -1404,7 +1408,7 @@ The following are `CREATE DATABASE` limitations:
14041408
14051409
## Permissions
14061410

1407-
To create a database, a login must be one of the following:
1411+
To create a database, a login must be one of the following types of security principals:
14081412

14091413
- The server-level principal login
14101414
- The Microsoft Entra administrator for the [logical server in Azure](/azure/azure-sql/database/logical-servers)
@@ -1489,6 +1493,7 @@ CREATE DATABASE database_name [ COLLATE collation_name ]
14891493
```
14901494

14911495
### [Serverless SQL pool](#tab/sqlod)
1496+
14921497
```syntaxsql
14931498
CREATE DATABASE database_name [ COLLATE collation_name ]
14941499
[;]
@@ -1690,7 +1695,9 @@ GO
16901695

16911696
Databases are created with database compatibility level 120, which is the compatibility level for [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)]. This ensures that the database will be able to use all of the [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)] functionality that PDW uses.
16921697

1693-
## Limitations and Restrictions
1698+
<a id="limitations-and-restrictions"></a>
1699+
1700+
## Limitations
16941701

16951702
The CREATE DATABASE statement is not allowed in an explicit transaction. For more information, see [Statements](../../t-sql/statements/statements.md).
16961703

@@ -1714,7 +1721,7 @@ After this operation succeeds, an entry for this database will appear in the [sy
17141721

17151722
### A. Basic database creation examples
17161723

1717-
The following example creates the database `mytest` with a storage allocation of 100 GB per Compute node for replicated tables, 500 GB per appliance for distributed tables, and 100 GB per appliance for the transaction log. In this example, AUTOGROW is off by default.
1724+
The following example creates the database `mytest` with a storage allocation of 100 GB per Compute node for replicated tables, 500 GB per appliance for distributed tables, and 100 GB per appliance for the transaction log. In this example, `AUTOGROW` is off by default.
17181725

17191726
```sql
17201727
CREATE DATABASE mytest
@@ -1724,7 +1731,7 @@ CREATE DATABASE mytest
17241731
LOG_SIZE = 100 GB );
17251732
```
17261733

1727-
The following example creates the database `mytest` with the same parameters as above, except that AUTOGROW is turned on. This allows the database to grow outside the specified size parameters.
1734+
The following example creates the database `mytest` with the same parameters, except that `AUTOGROW` is turned on. This allows the database to grow outside the specified size parameters.
17281735

17291736
```sql
17301737
CREATE DATABASE mytest

0 commit comments

Comments
 (0)