هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Exporting a Table

Updated on 2022-06-11 GMT+08:00

You can use gs_dump to export data and all object definitions of a table-level object from GaussDB(DWS). Views, sequences, and foreign tables are special tables. You can export one or more specified tables as needed. You can specify the information to be exported as follows:

  • Export full information of a table, including its data and definition.
  • Export data of a table.
  • Export the definition of a table.

Procedure

  1. Prepare an ECS as the gsql client host. For details, see "Preparing an ECS as the gsql Client Host" in the Data Warehouse Service (DWS) User Guide.
  2. Download the gsql client and use an SSH transfer tool (such as WinSCP) to upload it to the Linux server where gsql is to be installed. For details, see "Downloading the Client" in Data Warehouse Service User Guide.

    The user who uploads the client must have the full control permission on the target directory on the host to which the client is uploaded.

  3. Run the following commands to decompress the client:

    cd <Path_for_storing_the_client>
    unzip dws_client_8.1.x_redhat_x64.zip

    Where,

    • <Path_for_storing_the_client>: Replace it with the actual path.
    • dws_client_8.1.x_redhat_x86.zip: This is the client tool package of RedHat x86. Replace it with the actual one.

  4. Run the following command to configure the GaussDB(DWS) client:

    source gsql_env.sh

    If the following information is displayed, the GaussDB(DWS) client is successfully configured:

    All things done.

  5. Use gs_dump to run the following command to export the hr.staffs and hr.employments tables.

    gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup -p 8000 -h 10.10.10.100 human_resource -t hr.staffs -F d
    Table 1 Common parameters

    Parameter

    Description

    Example Value

    -U

    Username for connecting to the database. If this parameter is not configured, the username of the connected database is used.

    -U jack

    -W

    User password for database connection.

    • This parameter is not required for database administrators if the trust policy is used for authentication.
    • If you connect to the database without specifying this parameter and you are not a database administrator, you will be prompted to enter the password.

    -W Passwd@123

    -f

    Folder to store exported files. If this parameter is not specified, the exported files are stored in the standard output.

    -f /home//backup/MPPDB_table_backup

    -p

    Name extension of the TCP port on which the server is listening or the local Unix domain socket. This parameter is configured to ensure connections.

    -p 8000

    -h

    Cluster address: If a public network address is used for connection, set this parameter to Public Network Address or Public Network Domain Name. If a private network address is used for connection, set this parameter to Private Network Address or Private Network Domain Name.

    -h 10.10.10.100

    dbname

    Name of the database to be exported.

    human_resource

    -t

    Table (or view, sequence, foreign table) to be exported. You can specify multiple tables by listing them or using wildcard characters. When you use wildcard characters, quote wildcard patterns with single quotation marks ('') to prevent the shell from expanding the wildcard characters.

    • Single table: Enter -t schema.table.
    • Multiple tables: Enter -t schema.table for each table.
    • Single table: -t hr.staffs
    • Multiple tables: -t hr.staffs -t hr.employments

    -F

    Format of exported files. The values of -F are as follows:

    • p: plain text
    • c: custom
    • d: directory
    • t: .tar

    -F d

    For details about other parameters, see "gs_dump" in the Tool Guide.

Examples

Example 1: Use gs_dump to run the following command to export full information of the hr.staffs table. The exported files are in text format.
gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup.sql -p 8000 -h 10.10.10.100 human_resource -t hr.staffs -Z 6 -F p
gs_dump[port=''][human_resource][2017-07-21 17:05:10]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 17:05:10]: total time: 3116  ms
Example 2: Use gs_dump to run the following command to export data of the hr.staffs table. The exported files are in .tar format.
gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_data_backup.tar -p 8000 -h 10.10.10.100 human_resource -t hr.staffs -a -F t 
gs_dump[port=''][human_resource][2017-07-21 17:04:26]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 17:04:26]: total time: 2570  ms
Example 3: Use gs_dump to run the following command to export the definition of the hr.staffs table. The exported files are stored in a directory.
gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_def_backup -p 8000 -h 10.10.10.100 human_resource -t hr.staffs -s -F d 
gs_dump[port=''][human_resource][2017-07-21 17:03:09]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 17:03:09]: total time: 2297  ms 
Example 4: Use gs_dump to run the following command to export the human_resource database excluding the hr.staffs table. The exported files are in a custom format.
gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup4.dmp -p 8000 -h 10.10.10.100 human_resource -T hr.staffs -F c
gs_dump[port=''][human_resource][2017-07-21 17:14:11]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 17:14:11]: total time: 2450  ms
Example 5: Use gs_dump to run the following command to export the hr.staffs and hr.employments tables. The exported files are in text format.
gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup1.sql -p 8000 -h 10.10.10.100 human_resource -t hr.staffs -t hr.employments -F p
gs_dump[port=''][human_resource][2017-07-21 17:19:42]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 17:19:42]: total time: 2414  ms
Example 6: Use gs_dump to run the following command to export the human_resource database excluding the hr.staffs and hr.employments tables. The exported files are in text format.
gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup2.sql -p 8000 -h 10.10.10.100 human_resource -T hr.staffs -T hr.employments -F p
gs_dump[port=''][human_resource][2017-07-21 17:21:02]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 17:21:02]: total time: 3165  ms

Example 7: Use gs_dump to run the following command to export data and definition of the hr.staffs table, and the definition of the hr.employments table. The exported files are in .tar format.

gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup3.tar -p 8000 -h 10.10.10.100 human_resource -t hr.staffs -t hr.employments --exclude-table-data hr.employments -F t
gs_dump[port=''][human_resource][2018-11-14 11:32:02]: dump database human_resource successfully
gs_dump[port=''][human_resource][2018-11-14 11:32:02]: total time: 1645  ms

Example 8: Use gs_dump to run the following command to export data and definition of the hr.staffs table, encrypt the exported files, and store them in text format.

gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup4.sql -p 8000 -h 10.10.10.100 human_resource -t hr.staffs --with-encryption AES128 --with-key 1212121212121212 -F p
gs_dump[port=''][human_resource][2018-11-14 11:35:30]: dump database human_resource successfully
gs_dump[port=''][human_resource][2018-11-14 11:35:30]: total time: 6708  ms

Example 9: Use gs_dump to run the following command to export all tables, including views, sequences, and foreign tables, in the public schema, and the staffs table in the hr schema, including data and table definition. The exported files are in a custom format.

gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_table_backup5.dmp -p 8000 -h 10.10.10.100 human_resource -t public.* -t hr.staffs -F c
gs_dump[port=''][human_resource][2018-12-13 09:40:24]: dump database human_resource successfully
gs_dump[port=''][human_resource][2018-12-13 09:40:24]: total time: 896  ms

Example 10: Use gs_dump to run the following command to export the definition of the view referencing to the test1 table in the t1 schema. The exported files are in a custom format.

gs_dump -W Passwd@123 -U jack -f /home//backup/MPPDB_view_backup6 -p 8000 -h 10.10.10.100 human_resource -t t1.test1 --include-depend-objs --exclude-self -F d
gs_dump[port=''][jack][2018-11-14 17:21:18]: dump database human_resource successfully
gs_dump[port=''][jack][2018-11-14 17:21:23]: total time: 4239  ms

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback