Quickstart: Create a Hyperscale database in Azure SQL Database

In this quickstart, you create a logical server in Azure and a Hyperscale database in Azure SQL Database using the Azure portal, a PowerShell script, or an Azure CLI script, with the option to create one or more High Availability (HA) replicas. If you would like to use an existing logical server in Azure, you can also create a Hyperscale database using Transact-SQL.

Tip

Simplified pricing for SQL Database Hyperscale arrived in December 2023. Review the Hyperscale pricing blog for details.

Prerequisites

Permissions

To create databases via Transact-SQL: CREATE DATABASE permissions are necessary. To create a database a login must be either the server admin login (created when the Azure SQL Database logical server was provisioned), the Microsoft Entra admin of the server, a member of the dbmanager database role in master. For more information, see CREATE DATABASE.

To create databases via the Azure portal, PowerShell, Azure CLI, or REST API: Azure RBAC permissions are needed, specifically the Contributor, SQL DB Contributor, or SQL Server Contributor Azure RBAC role. For more information, see Azure RBAC built-in roles.

Create a Hyperscale database

This quickstart creates a single database in the Hyperscale service tier.

To create a Hyperscale database with Transact-SQL, you must first create or identify connection information for an existing logical server in Azure.

Connect to the master database using SQL Server Management Studio (SSMS), Azure Data Studio, or the client of your choice to run Transact-SQL commands (sqlcmd, etc.).

When creating a Hyperscale database, carefully consider the setting for BACKUP_STORAGE_REDUNDANCY. Storage redundancy can only be specified during the database creation process for Hyperscale databases. You can choose locally redundant, zone-redundant, or geo-redundant storage. The selected storage redundancy option will be used for the lifetime of the database for both data storage redundancy and backup storage redundancy. Existing databases can migrate to different storage redundancy using database copy or point in time restore. Allowed values for the BackupStorageRedundancy parameter are: LOCAL, ZONE, GEO. Unless explicitly specified, databases will be configured to use geo-redundant backup storage.

Run the following Transact-SQL command to create a new Hyperscale database with Gen 5 hardware, 2 vCores, and geo-redundant backup storage. You must specify both the edition and service objective in the CREATE DATABASE statement. Refer to the resource limits for a list of valid service objectives, such as HS_Gen5_2.

This example code creates an empty database. If you would like to create a database with sample data, use the Azure portal, Azure CLI, or PowerShell examples in this quickstart.

CREATE DATABASE [myHyperscaleDatabase] 
    (EDITION = 'Hyperscale', SERVICE_OBJECTIVE = 'HS_Gen5_2') WITH BACKUP_STORAGE_REDUNDANCY= 'LOCAL';
GO

Refer to CREATE DATABASE (Transact-SQL) for more parameters and options.

To add one or more High Availability (HA) replicas to your database, use the Compute and storage pane for the database in the Azure portal, the Set-AzSqlDatabase PowerShell command, or the az sql db update Azure CLI command.

Query the database

Once your database is created, you can use the Query editor (preview) in the Azure portal to connect to the database and query data. If you prefer, you can alternately query the database by connecting with Azure Data Studio, SQL Server Management Studio (SSMS), or the client of your choice to run Transact-SQL commands (sqlcmd, etc.).

  1. In the portal, search for and select SQL databases, and then select your database from the list.

  2. On the page for your database, select Query editor (preview) in the left menu.

  3. Enter your server admin login information, and select OK.

    Screenshot of the Query editor (preview) pane in Azure SQL Database gives two options for authentication. In this example, we have filled in Login and Password under SQL server authentication.

  4. If you created your Hyperscale database from the AdventureWorksLT sample database, enter the following query in the Query editor pane.

    SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
    FROM SalesLT.ProductCategory pc
    JOIN SalesLT.Product p
          ON pc.productcategoryid = p.productcategoryid;
    

    If you created an empty database using the Transact-SQL sample code, enter another example query in the Query editor pane, such as the following:

    CREATE TABLE dbo.TestTable(
        TestTableID int IDENTITY(1,1) NOT NULL,
        TestTime datetime NOT NULL,
        TestMessage nvarchar(4000) NOT NULL,
     CONSTRAINT PK_TestTable_TestTableID PRIMARY KEY CLUSTERED (TestTableID ASC)
    ) 
    GO
    
    ALTER TABLE dbo.TestTable ADD CONSTRAINT DF_TestTable_TestTime  DEFAULT (getdate()) FOR TestTime
    GO
    
    INSERT dbo.TestTable (TestMessage)
    VALUES (N'This is a test');
    GO
    
    SELECT TestTableID, TestTime, TestMessage
    FROM dbo.TestTable;
    GO
    
  5. Select Run, and then review the query results in the Results pane.

    Screenshot of the Query editor (preview) pane in Azure SQL Database after a query has been run against AdventureWorks sample data.

  6. Close the Query editor page, and select OK when prompted to discard your unsaved edits.

Clean up resources

Keep the resource group, server, and single database to go on to the next steps, and learn how to connect and query your database with different methods.

When you're finished using these resources, you can delete the resource group you created, which will also delete the server and single database within it.

This option deletes only the Hyperscale database. It doesn't remove any logical servers or resource groups that you might have created in addition to the database.

To delete a Hyperscale database with Transact-SQL, connect to the master database using SQL Server Management Studio (SSMS), Azure Data Studio, or the client of your choice to run Transact-SQL commands (sqlcmd, etc.).

Run the following Transact-SQL command to drop the database:

DROP DATABASE [myHyperscaleDatabase];
GO

Connect and query your database using different tools and languages:

Learn more about Hyperscale databases in the following articles: