Help Center/ Relational Database Service/ Getting Started/ Getting Started with RDS for PostgreSQL/ Example: Buy and Connect to an RDS for PostgreSQL DB Instance
Updated on 2024-03-19 GMT+08:00

Example: Buy and Connect to an RDS for PostgreSQL DB Instance

This example illustrates how to purchase an RDS for PostgreSQL instance and how to connect to it using DAS.

Step 1: Create an RDS for PostgreSQL Instance

  1. Go to the Buy DB Instance page.
  2. Configure the instance information and click Next.
    Figure 1 Selecting a billing mode, DB engine, storage type, and instance type
    Figure 2 Selecting an instance class
    Figure 3 Configuring network information
    Figure 4 Setting a password
  3. View the purchased RDS instance.
    Figure 5 Instance successfully purchased

Step 2: Connect to the RDS for PostgreSQL Instance

  1. Click Log In in the Operation column.
    Figure 6 Instances
  2. Enter the root password you configured during instance creation and click Log In.
    Figure 7 Instance login
  3. Choose SQL Operations > SQL Query.
    Figure 8 SQL Query
  4. Create a database named test1.

    CREATE DATABASE test1;

    Figure 9 Creating a database
  5. Switch to test1 and create a schema named schema1 in the database.
    Figure 10 Switching to the database

    CREATE SCHEMA schema1;

    Figure 11 Creating a schema
  6. Switch to schema1 and create a table named mytable with only one column. Specify the column name as firstcol and the column type as integer.

    CREATE TABLE schema1.mytable (firstcol int);

    Figure 12 Creating a table
  7. Insert data to the table.

    INSERT INTO schema1.mytable values (100);

    Figure 13 Inserting data

    Query data in the table.

    SELECT * FROM "schema1"."mytable"

    Figure 14 Querying data
  8. In the upper part of the page, choose Account Management > Role Management.
    Figure 15 Role management
  9. Click Create Role and complete basic settings. user1 is used as an example.
    Figure 16 Creating a role
  10. Click the Permissions tab and grant user1 the permissions to perform operations on databases, schemas, and tables.
    Figure 17 Granting permissions
  11. On the Development Tool page, click Add Login and log in to the database as user1.
    Figure 18 Adding login
  12. Create schema2 in test1 to verify that user1 has the CREATE permission.
    CREATE SCHEMA schema2;
    Figure 19 Verifying permissions