CREATE SERVER
Function
CREATE SERVER creates a foreign server.
A foreign server stores OBS server information or other homogeneous cluster information.
Precautions
Only a system administrator and users with permission to use a specified FOREIGN DATA WRAPPER can create a foreign server. The authorization syntax is as follows:
GRANT USAGE ON FOREIGN DATA WRAPPER fdw_name TO username
fdw_name is the name of the FOREIGN DATA WRAPPER, and username is the name of the user creating a foreign server.
When multi-layer quotation marks are used for sensitive columns (such as password and secret_access_key) in OPTIONS, the semantics is different from that in the scenario where quotation marks are not used. Therefore, sensitive columns are not identified for anonymization.
Syntax
1 2 3 |
CREATE SERVER server_name FOREIGN DATA WRAPPER fdw_name OPTIONS ( { option_name ' value ' } [, ...] ) ; |
Parameter Description
- server_name
Specifies the server name.
Value range: a string containing no more than 63 characters
- FOREIGN DATA WRAPPER fdw_name
Specifies the name of the foreign data wrapper.
Value range: fdw_name is the data wrapper created by the system during database initialization. Currently, fdw_name can only be gc_fdw for other homogeneous clusters. You can also create dist_fdw, file_fdw, and log_fdw.
- OPTIONS ( { option_name ' value ' } [, ...] )
Specifies the parameters for the foreign server. The detailed parameter description is as follows:
- encrypt
Specifies whether data is encrypted. This parameter is available only when type is OBS. The default value is on.
Value range:
- on indicates that data is encrypted and HTTPS is used for communication.
- off indicates that data is not encrypted and HTTP is used for communication.
- access_key
Specifies the access key (AK) (obtained by users from the OBS console) used for the OBS access protocol. When you create a foreign table, the AK value is encrypted and saved to the metadata table of the database. This parameter is available only when type is set to OBS.
- secret_access_key
Specifies the secret key (SK) value (obtained by users from the OBS console) used for the OBS access protocol. When you create a foreign table, the SK value is encrypted and saved to the metadata table of the database. This parameter is available only when type is set to OBS.
- encrypt
Examples
Create my_server, in which file_fdw is the built-in foreign data wrapper.
1 2 3 4 5 |
-- Create my_server. gaussdb=# CREATE SERVER my_server FOREIGN DATA WRAPPER file_fdw; -- Delete my_server. gaussdb=# DROP SERVER my_server; |
Create another server in the homogeneous cluster, where gc_fdw is the foreign data wrapper in the database.
1 2 3 4 5 6 7 8 9 10 |
-- Create a server. gaussdb=# CREATE SERVER server_remote FOREIGN DATA WRAPPER GC_FDW OPTIONS (address '10.146.187.231:8000,10.180.157.130:8000' , dbname 'test', username 'test', password '********' ); -- Delete the server. gaussdb=# DROP SERVER server_remote; |
Helpful Links
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot