PostgreSQL is an open-source and advanced RDS that supports both SQL (relational) and JSON (non-relational) queries. Amazon RDS service allows the user to create database instances using the PostgreSQL engine on the cloud. The pgAdmin application can be used to connect to the DB instance and create databases on it.
This guide will explain how to create an RDS PostgreSQL database in pgAdmin.
Creating an AWS RDS PostgreSQL Database in pgAdmin
To create a database in pgAdmin, create a DB instance in the AWS RDS dashboard and click on the “View connection details” button:
This page contains the connection credentials which will be used later to connect to the pgAdmin:
Open the pgAdmin application from the local system:
Provide the password for the application and click on the “OK” button:
Click on the “Add New Server” button from the “Quick Links” section:
Type the name of the server in the “General” page:
Head into the “Connection” page to provide the credentials like Endpoint in the Host name/address tab, username, and password of the DB instance. These credentials can be found on the AWS RDS dashboard mentioned above and after that, click on the “Save” button:
The server has been added to the pgAdmin and its dashboard is visible on the screen:
Right-click on the “Databases” button from the server, expand the “Create” menu, and click on the “Database…” button:
Type the name of the database and click on the “Save” button:
Right-click on the name of the database to open the menu and click on the “Query Tool” button from the list:
Type the following query in the query tool to create a new table:
CREATE TABLE test ( ID SERIAL PRIMARY KEY, testID VARCHAR(50), testhistory VARCHAR(600), CREATED TIMESTAMP );
Run the above query by clicking on the “run” icon given in the navigation bar. It will create a table named “test” which contains “ID” as its primary key, “testID”, “testhistory” and “CREATED” as its fields:
Insert the data into the test table using the following query:
INSERT INTO test (testID, testhistory, CREATED) VALUES ('test#4854', '{}', NOW());
The above query contains:
- INSERT INTO contains the name of the fields for the test database.
- VALUES contain the data to be inserted in these fields:
Use the “SELECT” query with the “*” symbol to fetch all fields of a table:
SELECT * FROM test;
The above query will fetch everything available in the test table:
That’s all about creating an AWS RDS PostgreSQL database in pgAdmin.
Conclusion
To create an AWS RDS PostgreSQL database in pgAdmin, connect to the DB instance by providing its credentials from the pgAdmin application. After that, create a database from the server added to pgAdmin and configure it before saving it. Open a Query tool to perform any database operation using the queries. This guide has explained the process of how to create an AWS RDS PostgreSQL database in pgAdmin.