sql azure 语法

In this article, we will review CREATE DATABASE statement in the Azure SQL database with various examples.

在本文中,我们将通过各种示例回顾Azure SQL数据库中的CREATE DATABASE语句。

CREATE DATABASE command is used to create a database in on-premises SQL Server or a database in Azure SQL Server. The syntax of CREATE DATABASE is a bit different in Azure SQL Server compared to on-premises SQL Server or a SQL Server on Azure VM.

CREATE DATABASE命令用于在本地SQL Server中创建数据库或在Azure SQL Server中创建数据库。 与本地SQL Server或Azure VM上SQL Server相比,Azure SQL Server中的CREATE DATABASE语法有点不同。

We will discuss a few examples of creating a database using CREATE DATABASE statement in Azure SQL Server.

我们将讨论一些在Azure SQL Server中使用CREATE DATABASE语句创建数据库的示例。

句法 (Syntax)

The following is the basic syntax of creating a database in Azure SQL Server.

以下是在Azure SQL Server中创建数据库的基本语法。

CREATE DATABASE DBName

For example:

例如:

CREATE DATABASE DemoDB

If no other options are specified, the database is created on the Azure SQL Server where the CREATE DATABASE command was executed with the default configuration. i.e. the database is created with edition “General Purpose” with service objective “Gen5, 2 vCores”. The max size property is set to 32 GB.

如果未指定其他选项,则会在使用默认配置执行CREATE DATABASE命令的Azure SQL Server上创建数据库。 即,数据库的创建版本为“通用”,服务目标为“ Gen5,2个vCore”。 最大大小属性设置为32 GB。

通过指定版本创建数据库 (Creating a database by specifying the edition)

Following is the syntax of creating a database in the specific edition.

以下是在特定版本中创建数据库的语法。

CREATE DATABASE DemoDB2
( EDITION = 'basic') ;

The above statement creates a database in the Azure SQL Server with a basic edition. If you do not specify the max size option, the max size of the database is set to the default value in basic edition i.e. 2 GB

上面的语句在Azure SQL Server中使用基本版本创建数据库。 如果未指定最大大小选项,则数据库的最大大小将设置为基本版中的默认值,即2 GB

Below are the different types of editions in the Azure SQL database.

下面是Azure SQL数据库中不同类型的版本。

  • BASIC EDITION 基本版
  • STANDARD EDITION 标准版
  • PREMIUM EDITION 高级版
  • GENERAL PURPOSE EDITION 通用版
  • HYPER SCALE EDITION 超比例版
  • BUSINESS CRITICAL EDITION 商业关键版

The following example creates a database in Azure SQL Server with service objective “S0” and Standard edition. As we specified the MAXSIZE option, the max size of the database is set to 500 MB. The allowed max size value of a database in the standard edition is 250 GB.

下面的示例在Azure SQL Server中创建一个服务目标为“ S0”和标准版的数据库。 正如我们指定的MAXSIZE选项一样,数据库的最大大小设置为500 MB。 标准版本中数据库允许的最大大小值为250 GB。

CREATE DATABASE DemoDB</p>
( EDITION = 'standard', SERVICE_OBJECTIVE = 'S0', MAXSIZE = 500 MB ) ;

Let us see how to create a database equivalent to the above T-SQL script from the Azure portal.

让我们看看如何从Azure门户创建与上述T-SQL脚本等效的数据库。

Log in to the Azure portal. Navigate to SQL databases and click on Add.

登录到Azure门户。 导航到SQL数据库 ,然后单击“ 添加”。

Enter the name of the database and select the Azure SQL Server. Click on Configure database as shown in the below image.

输入数据库的名称,然后选择Azure SQL Server。 单击“ 配置数据库” ,如下图所示。

Select the edition like Standard and service objective as S0. Set the max size and click on Apply.

选择“标准”和“服务目标”等版本作为S0。 设置最大大小,然后单击“ 应用”。

Click on Review + Create and then Create.

单击Review + Create ,然后单击Create。

数据库的默认MAXSIZE (Default MAXSIZE of the database)

Below are the default values of max size as per edition and service level objective.

以下是根据版本和服务级别目标的最大大小的默认值。

  • For a database in the basic version, the default max size is 2 GB and for a database standard edition, the default max size is 250 GB 对于基本版本的数据库,默认最大大小为2 GB,对于数据库标准版本,默认最大大小为250 GB
  • If you are using a premium version the default max size depends on the service objective of the database 如果使用的是高级版本,则默认最大大小取决于数据库的服务目标。
  • If the service objective is between P1-P6, then the default max size is 500 GB and if the service objective is between P11-P15, the default max size IS 1024 GB 如果服务目标在P1-P6之间,则默认最大大小为500 GB;如果服务目标在P11-P15之间,则默认最大大小为1024 GB
  • vCore model, the default max size is 32 GB vCore模型的其他版本,默认最大大小为32 GB

在弹性池中创建数据库 (Creating a database in an elastic pool)

To create a database in an elastic pool using the CREATE DATABASE statement, the elastic pool must be pre-existing.

要使用CREATE DATABASE语句在弹性池中创建数据库,该弹性池必须是预先存在的。

So, the database can be in an existing elastic pool only.

因此,数据库只能位于现有的弹性池中。

Following is the syntax of creating a database in an existing elastic pool. This script creates a database with the name DemoDB in the elastic pool “DemoPool”.

以下是在现有弹性池中创建数据库的语法。 该脚本在弹性池“ DemoPool”中创建一个名称为DemoDB的数据库。

CREATE DATABASE DemoDB( SERVICE_OBJECTIVE = ELASTIC_POOL ( name = DemoPool ) ) ;

从现有数据库创建数据库 (Creating a database from an existing database)

By using ‘AS COPY OF’ clause in CREATE DATABASE statement, we can create a copy of the database existing in the same or different server. Please note that the edition of the new database cannot be changed with the AS COPY OF clause. We can only change the service objective of the new database.

通过在CREATE DATABASE语句中使用“ AS COPY OF”子句,我们可以创建存在于相同或不同服务器中的数据库的副本。 请注意,不能使用AS COPY OF子句更改新数据库的版本。 我们只能更改新数据库的服务目标。

Following is the example of creating a database from a copy of an existing database within the same Azure SQL Server.

以下是从同一Azure SQL Server中现有数据库的副本创建数据库的示例。

CREATE DATABASE DemoDB</p>
AS COPY OF SampleDB

If the service objective is not specified while creating a database, the new database which is copied from the existing database is created with the same service objective.

如果在创建数据库时未指定服务目标,则将使用相同的服务目标来创建从现有数据库复制的新数据库。

Below is the T-SQL script to create a new database from an existing database by changing the service objective.

下面是通过更改服务目标从现有数据库创建新数据库的T-SQL脚本。

CREATE DATABASE DemoDB</p>AS COPY OF SampleDB(SERVICE_OBJECTIVE = 'S1' ) ;

If you want to create a copy of a database from an existing database in another server, just specify the server name. In this case, rbc2 is the server name where existing database SampleDB exists. You do not need to specify the fully qualified server name.

如果要从另一台服务器中的现有数据库创建数据库副本,只需指定服务器名称即可。 在这种情况下,rbc2是现有数据库SampleDB所在的服务器名称。 您不需要指定标准服务器名称。

CREATE DATABASE DemoDBAS COPY OF rbc2.SampleDB(SERVICE_OBJECTIVE = 'S1' );

在Azure SQL数据库托管实例中创建数据库 (Creating a database in Azure SQL Database Managed Instance)

To create a database in Azure SQL Database Managed Instance, just use CREATE DATABASE statement with the database name and specify the collation of the database. We cannot specify files and filegroups while creating a database. Use ALTER DATABASE to add new files if any.

若要在Azure SQL数据库托管实例中创建数据库,只需将CREATE DATABASE语句与数据库名称一起使用并指定数据库的排序规则。 创建数据库时,我们无法指定文件和文件组。 使用ALTER DATABASE添加新文件(如果有)。

CREATE DATABASE DemoDB COLLATE SQL_Latin1_General_CP1_CI_AS

结论 (Conclusion)

In this article, we explored CREATE DATABASE statement in Azure SQL Server with different examples and created a database using the Azure portal. In case you have any questions, please feel free to ask in the comment section below.

在本文中,我们使用不同的示例探索了Azure SQL Server中的CREATE DATABASE语句,并使用Azure门户创建了一个数据库。 如果您有任何疑问,请随时在下面的评论部分中提问。

翻译自: https://www.sqlshack.com/overview-of-create-database-statement-in-azure-sql-server/

sql azure 语法

sql azure 语法_Azure SQL Server中的CREATE DATABASE语句概述相关推荐

  1. sql azure 语法_Azure Data Studio中SQL Server Profiler

    sql azure 语法 In this article, we will explore SQL Server Profiler in Azure Data Studio in detail inc ...

  2. sql azure 语法_Azure Data Studio中SQL Server架构比较扩展

    sql azure 语法 This article explores the SQL Server Schema Compare extension in the Azure Data Studio. ...

  3. sql azure 语法_Azure SQL Server自动故障转移组

    sql azure 语法 In this article, we will review how to set up auto-failover groups in Azure SQL Server ...

  4. sql azure 语法_Azure Data Studio中SQL代码段

    sql azure 语法 This article will fully cover the code snippet SQL developer productivity feature in Az ...

  5. sql azure 语法_Azure SQL –使用Azure自动化的索引表

    sql azure 语法 This article provides an overview of indexing tables in Azure SQL database using Azure ...

  6. sql azure 语法_Azure SQL数据同步–在Azure SQL数据库之间复制数据和架构更改

    sql azure 语法 In this article, we will review how to configure the sync group to replicate data betwe ...

  7. sql azure 语法_Azure SQL –弹性作业代理

    sql azure 语法 In this article, we will review on elastic job Agent in Azure SQL and how to configure ...

  8. sql azure 语法_Azure Kubernetes服务(AKS)中SQL Server

    sql azure 语法 In this article, we will review how to create a Kubernetes cluster in Azure Kubernetes ...

  9. sql azure 语法_Azure中的新SQL数据仓库

    sql azure 语法 介绍 (Introduction) In previous chapters, we taught how to create SQL Databases in Azure. ...

最新文章

  1. “拯救网站运维经理赵明”有奖方案征集启事
  2. 【Codeforces 631C 】Report(单调栈,思维模拟)
  3. OpenCV深度学习人脸识别示例——看大佬如何秀恩爱
  4. 上海交大发布全球首款专用光量子计算软件
  5. .class 字节码文件与Java RTTI(类型信息)(.class 类对象)
  6. kubernetes 日志定制查阅 - 排错 -- 好用的命令
  7. doc 问卷调查模板表_幼儿园家长问卷调查表
  8. c语言 美元符号,汇编语言 美元符号
  9. stm32 火灾自动报警及联动控制源码_火灾自动报警系统和消防联动系统的区别
  10. Macbook Pro 外接显示器关闭內建屏幕的方法,开盖状态
  11. 余压监控系统在某高层住宅的应用方案
  12. 车载播放器 android,KX万能播放器
  13. c语言输出字母是问号,为什么数组输出会多一个问号
  14. matlab解二阶微分方程组ode,MATLAB解含参数方程、矩阵方程、二阶微分方程组
  15. Android 简单跟踪重力传感器方向旋转屏幕framework的代码
  16. 用于记录解决Fermi望远镜处理数据报错
  17. MBA数学备考指南,不看你后悔
  18. 2022年第十三届蓝桥杯大赛软件类决赛C/C++大学B组E题出差
  19. 论文翻译:基于端到端的可训练神经网络基于图像的序列识别及其在场景文本识别中的应用
  20. 使用key 发smtp.sendgrid.net_【点亮人生】微信上从来不发朋友圈的男人,不是低调,十有八九是这三种人...

热门文章

  1. 蓝桥杯 传球游戏 动态规划
  2. jQuery多选列表框插件Multiselect
  3. 高性能JavaScript(您值得一看)
  4. 第二届360杯全国大学生信息安全技术大赛部分解题思路(加密解密题)
  5. 【零基础学Java】—包装类(三十七)
  6. jQuery学习(九)—常用的包裹方法
  7. codeforce438D The Child and Sequence
  8. DLog-M什么意思
  9. 过几天就退休了,目前情况下可不可以请同事们吃饭呢?
  10. 闺女在大连上大学,一个月1500生活费她说少