To obtain access keys, log in to the management console, click the username in the upper right corner, and select My Credential from the menu. Then choose Access Keys in the navigation tree on the left. On the Access Keys page, you can view the existing AKs or click Add Access Key to create and download access keys.
For example, in the GaussDB(DWS) database, create a write-only foreign table with the format parameter as text to export text files. Set parameters as follows:
The OBS path of the source data file has been obtained in Obtain the OBS path for storing source data files in Planning Data Export.
For example, set location as follows:
location 'obs://mybucket/output_data/',
access_key and secret_access_key have been obtained during user creation. Replace the italic part with the actual keys.
Based on the above settings, the foreign table is created using the following statement:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | DROP FOREIGN TABLE IF EXISTS product_info_output_ext1; CREATE FOREIGN TABLE product_info_output_ext1 ( c_bigint bigint, c_char char(30), c_varchar varchar(30), c_nvarchar2 nvarchar2(30) , c_data date, c_time time , c_test varchar(30)) server gsmpp_server options ( LOCATION 'obs://mybucket/output_data/', ACCESS_KEY 'access_key_value_to_be_replaced', SECRET_ACCESS_KEY 'secret_access_key_value_to_be_replaced' format 'text', delimiter '|', encoding 'utf-8', encrypt 'on' ) WRITE ONLY; |
If the following information is displayed, the foreign table has been created:
CREATE FOREIGN TABLE
For example, in the GaussDB(DWS) database, create a write-only foreign table with the format parameter as CSV to export CSV files. Set parameters as follows:
The OBS path of the source data file has been obtained in Obtain the OBS path for storing source data files in Planning Data Export.
For example, set location as follows:
location 'obs://mybucket/output_data/',
access_key and secret_access_key have been obtained during user creation. Replace the italic part with the actual keys.
Specifies whether a file contains a header with the names of each column in the file.
When exporting data from OBS, this parameter cannot be set to true. Use the default value false, indicating that the first row of the exported data file is not the header.
Based on the preceding settings, the foreign table is created using the following statements:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | DROP FOREIGN TABLE IF EXISTS product_info_output_ext2; CREATE FOREIGN TABLE product_info_output_ext2 ( product_price integer not null, product_id char(30) not null, product_time date , product_level char(10) , product_name varchar(200) , product_type1 varchar(20) , product_type2 char(10) , product_monthly_sales_cnt integer , product_comment_time date , product_comment_num integer , product_comment_content varchar(200) ) SERVER gsmpp_server OPTIONS( location 'obs://mybucket/output_data/', FORMAT 'CSV' , DELIMITER ',', encoding 'utf8', header 'false', ACCESS_KEY 'access_key_value_to_be_replaced', SECRET_ACCESS_KEY 'secret_access_key_value_to_be_replaced' ) WRITE ONLY ; |
If the following information is displayed, the foreign table has been created:
CREATE FOREIGN TABLE