Relational Database ServiceRelational Database Service

Compute
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Anti-DDoS
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Compass
Cloud Certificate Manager
Anti-DDoS Service
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB NoSQL
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
ServiceStage
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain Service
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
DevCloud
ProjectMan
CodeHub
CloudRelease
CloudPipeline
CloudBuild
CloudDeploy
Cloud Communications
Message & SMS
Cloud Ecosystem
Marketplace
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
enterprise-collaboration
Meeting
IoT
IoT
Intelligent EdgeFabric
DeveloperTools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Updated at: Apr 02, 2022 GMT+08:00

Tablespace Management

Scenarios

RDS provides the PostgreSQL tablespace management solution based on user root.

Creating a Tablespace

  1. Connect to the database as user root and create a tablespace.

    # psql --host=<RDS_ADDRESS> --port=<DB_PORT> --dbname=<DB_NAME> --username=root -c "select control_tablespace ('create', '<TABLESPACE_NAME>');"

    Table 1 Parameter description

    Parameter

    Description

    RDS_ADDRESS

    Indicates the IP address of the RDS DB instance.

    DB_PORT

    Indicates the port of the RDS DB instance.

    DB_NAME

    Indicates the database name.

    TABLESPACE_NAME

    Indicates the tablespace name.

  2. Enter the password of user root when prompted.

    Log in to the my_db database and create the tbspc1 tablespace. Example:

    # psql --host=192.168.6.141 --port=5432 --dbname=my_db --username=root -c "select control_tablespace('create', 'tbspc1');"

    Password for user root:
              control_tablespace          
    ------------------------------    
    create tablespace tbspc1 successfully.   
    (1 row)

    If the creation fails, view error logs of the DB instance.

    To ensure performance, a maximum of 100 tablespaces can be created.

Granting Tablespace Permissions

  1. Connect to a database as user root and grant the tablespace usage permissions to specified users.

    # psql --host=<RDS_ADDRESS> --port=<DB_PORT> --dbname=<DB_NAME> --username=root -c "select control_tablespace ('alter', '<TABLESPACE_NAME>', '<USER_NAME>');"

    Table 2 Parameter description

    Parameter

    Description

    RDS_ADDRESS

    Indicates the IP address of the RDS DB instance.

    DB_PORT

    Indicates the port of the RDS DB instance.

    DB_NAME

    Indicates the database name.

    TABLESPACE_NAME

    Indicates the tablespace name.

    USER_NAME

    Indicates the tablespace username.

  2. Enter the password of user root when prompted.

    Log in to the my_db database and grant permissions to tablespace tbspc1, for example:

    # psql --host=192.168.6.141 --port=5432 --dbname=my_db --username=root -c "select control_tablespace('alter', 'tbspc1', 'user1');"

    Password for user root:
             control_tablespace         
    ----------------------------    
    alter tablespace tbspc1 successfully.   
    (1 row)

    If the permissions fail to be granted, view error logs of the DB instance.

Deleting a Tablespace

  1. Connect to a database as user root and delete a tablespace.

    # psql --host=<RDS_ADDRESS> --port=<DB_PORT> --username=root --dbname=<DB_NAME> -c "select control_tablespace('drop', '<TABLESPACE _NAME>');"

    Table 3 Parameter description

    Parameter

    Description

    RDS_ADDRESS

    Indicates the IP address of the RDS DB instance.

    DB_PORT

    Indicates the port of the RDS DB instance.

    DB_NAME

    Indicates the database name.

    TABLESPACE_NAME

    Indicates the tablespace name.

  2. Enter the password of user root when prompted.

    Example:

    # psql --host=192.168.6.141 --port=8635 --dbname=my_db --username=root -c "select control_tablespace('drop', 'tbspc1');"

    Password for user root:
             control_tablespace         
    ----------------------------    
    drop tablespace tbspc1 successfully.   
    (1 row)

    Before deleting the tablespace, ensure that it is empty. If the deletion fails, view error logs of the DB instance.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel