After completing operations in this tutorial, if you no longer need to use the resources created during the operations, you can delete them to avoid resource waste or quota occupation. The procedure is as follows:
If you have performed steps in (Optional) Creating a User and a Database and Granting the User Foreign Table Permissions, delete the database and the user to which the database belongs.
1 | DROP TABLE product_info; |
If the following information is displayed, the table has been deleted.
DROP TABLE
1 | DROP FOREIGN TABLE product_info_ext_obs; |
If the following information is displayed, the table has been deleted.
DROP FOREIGN TABLE
In this example, common user dbuser is used to create the foreign server in mydatabase. You need to connect to the database through the database client tool provided by GaussDB(DWS). You can use the gsql client to log in to the database in either of the following ways:
1 | \c mydatabase dbuser; |
Enter the password as prompted.
1 | gsql -d mydatabase -h 192.168.2.30 -U dbuser -p 8000 -r |
Enter the password as prompted.
Run the following command to delete the server. For details about the syntax, see DROP SERVER.
1 | DROP SERVER obs_server; |
The database is deleted if the following information is displayed:
DROP SERVER
View the foreign server.
1 | SELECT * FROM pg_foreign_server WHERE srvname='obs_server'; |
The server is successfully deleted if the returned result is as follows:
srvname | srvowner | srvfdw | srvtype | srvversion | srvacl | srvoptions ---------+----------+--------+---------+------------+--------+------------ (0 rows)
If you have performed steps in (Optional) Creating a User and a Database and Granting the User Foreign Table Permissions, perform the following steps to delete the database and the user to which the database belongs.
Connect to the default database gaussdb through the database client tool provided by GaussDB(DWS).
If you have logged in to the database using the gsql client, run the following command to switch the database and user:
Switch to the default database.
\c gaussdb
Enter your password as prompted.
Run the following command to delete the customized database:
1 | DROP DATABASE mydatabase; |
The database is deleted if the following information is displayed:
DROP DATABASE
Connect to the database as a database administrator through the database client tool provided by GaussDB(DWS).
If you have logged in to the database using the gsql client, run the following command to switch the database and user:
\c gaussdb dbadmin
1 | REVOKE ALL ON FOREIGN DATA WRAPPER dfs_fdw FROM dbuser; |
The name of FOREIGN DATA WRAPPER must be dfs_fdw. dbuser is the username for creating SERVER.
Run the following command to delete the user:
1 | DROP USER dbuser; |
You can run the \du command to query for the user and check whether the user has been deleted.