All Products
Search
Document Center

Hologres:Create a database

最終更新日:Oct 28, 2024

This topic describes how to create a database in the Hologres console or from the PostgreSQL client.

Prerequisites

A Hologres instance is purchased. For more information, see Purchase a Hologres instance.

Background information

After you purchase a Hologres instance, a database named postgres is automatically created. This database is allocated with a few resources and used only for management purposes. Therefore, we recommend that you create another database to process business data.

Only a superuser or a user granted the database creation permissions can create a database.

Create a database in the Hologres console

  1. Log on to the Hologres console. In the left-side navigation pane, click Instances.

  2. On the Hologres Instances page, find the instance for which you want to create a database and click the instance name.

    You can also find the instance for which you want to create a database and click Manage in the Actions column to go to the instance details page.

  3. In the left-side navigation pane of the instance details page, click Database Management.

  4. On the Database Authorization page, click Create Database in the upper-right corner.

  5. In the Create Database dialog box, select the name of the instance for which you want to create the database from the Instance Name drop-down list, enter a database name in the Database Name field, and then specify a permission model based on your business needs by setting the SPM parameter. We recommend that you select SPM.

    Permission model

    Description

    Simple permission model (SPM)

    If the SPM is used, permissions are granted at the database level. The following user groups are provided: admin, developer, writer, and viewer. You need to use only a few functions to manage the permissions on the objects in a database in a convenient and secure way. For more information, see Overview.

    Schema-level permission model (SLPM)

    If the SLPM is used, permissions are granted at the schema level. The following user groups are provided: <db>.admin, <db>.<schema>.developer, <db>.<schema>.writer, and <db>.<schema>.viewer. Compared with the SPM, the SLPM manages permissions in a more fine-grained manner. For more information, see Overview.

    Standard PostgreSQL authorization model

    Hologres allows you to use the standard PostgreSQL authorization model. For more information, see Standard PostgreSQL authorization model.

    Create Database

  6. Click OK.

    You can view the created database on the Database Authorization page.

Create a database from the PostgreSQL client

  1. Connect to the Hologres instance for which you want to create a database from the PostgreSQL client. For more information, see Use the PostgreSQL client to connect to Hologres.

  2. Create a database. Sample statements:

    CREATE Database NewDatabaseName;
    CREATE Database test; --Create a database named test. 
  3. Run the \l command to view the databases in the instance.

  4. Run the \c NewDatabaseName command to connect to the newly created database. When you run this command, replace NewDatabaseName with the name of the created database.

What to do next

Execute standard PostgreSQL statements to analyze data from the PostgreSQL client. For example, you can execute SQL statements to import MaxCompute data to Hologres. For more information, see Import data from MaxCompute to Hologres by executing SQL statements.

You can also use HoloWeb to analyze data. For more information, see Connect to HoloWeb and perform queries.