Create a database

更新时间:
复制 MD 格式

After you create an ApsaraDB RDS for SQL Server instance, you must create databases on the instance for your applications. This topic describes how to create a database and plan the number of databases to meet your business requirements.

Prerequisites

An ApsaraDB RDS for SQL Server instance is created. For instructions, see Create an ApsaraDB RDS for SQL Server instance.

Database limits

The maximum number of databases for an instance that runs SQL Server 2008 R2 is 50. For other SQL Server versions, the maximum number of databases depends on the instance specifications. The limit is calculated based on the following formulas:

  • Cluster Edition / High-availability Edition

    The maximum number of databases is the minimum of 300 and the value obtained by taking the square root of the number of CPU cores, rounding the result down to the nearest integer, and then multiplying it by 50. For example, a 2016 Standard High-availability Edition (4-core 8 GB) instance supports a maximum of 100 databases.

  • Basic Edition

    A base value is calculated by taking the square root of the number of CPU cores, rounding down to the nearest integer, and then multiplying the result by 100. The maximum number of databases is the minimum of this base value and 400. For example, a 2019 Standard Basic Edition (4-core 8 GB) instance supports a maximum of 200 databases.

Note

The min function returns the smallest value in a set of numbers. For example, min(100, 300) returns 100.

Create a database

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the left-side navigation pane, click Databases.

  3. Click Create Database, configure the following parameters, and then click Create.

    Parameter

    Description

    Database Name

    Enter a name for the database. The name must be 2 to 64 characters in length, start with a letter, and end with a letter or digit. It can contain uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-). Chinese characters are not supported.

    Supported Character Set

    Select a character set for the database.

    Description

    Enter a description for the database. The description can be up to 256 characters in length.

Related operations

  • You can also call the CreateDatabase API operation to create a database on an ApsaraDB RDS for SQL Server instance.

  • You can use various methods to connect to your SQL Server instance, such as Data Management (DMS) or a SQL Server Management Studio (SSMS) client.

FAQ

Error: Duplicate database name

Issue

When you create a database on the Databases page of an ApsaraDB RDS for SQL Server instance, the error message The database name is invalid. Please specify a new database name. is returned. The error code is InvalidDBName.Duplicate.

image

Cause

Also, the Databases page of an ApsaraDB RDS for SQL Server instance displays only databases with the ONLINE status. Databases that are not in the ONLINE status (such as RESTORING, RECOVERING, or OFFLINE) are not displayed in the console. Therefore, you may mistakenly believe that the database does not exist, which can lead to creation failures.

Solution

  1. Connect to an SQL Server instance

  2. image

Error: Database limit reached

  • Cause: This error indicates that your ApsaraDB RDS for SQL Server instance has reached the maximum number of databases allowed for its specifications. For information about how the limits are calculated, see the Database limits section in this topic.

  • Solution: To increase the database limit, you can upgrade the instance specifications.

Database naming conventions

No. Using Chinese characters in database names can cause compatibility issues, script parsing difficulties, migration risks, and management complexity. In ApsaraDB RDS for SQL Server, a database name must be 2 to 64 characters long, start with a letter, end with a letter or digit, and contain only uppercase letters, lowercase letters, digits, underscores (_), or hyphens (-). Adhering to these naming conventions ensures system stability and maintainability.