Saturday, 18 October 2025

Steps to Create and Connect to Azure Database for PostgreSQL

Steps to Create and Connect to Azure Database for PostgreSQL

  1. Create PostgreSQL Database in Azure Portal
    • Go to the Azure Portal.
    • Search for and select Azure Database for PostgreSQL servers.
    • Click Create, then select Flexible Server option.








  2. Get Connection Information
    • In the newly created server’s Overview page, copy the Server name and Username; you will need these to connect.
  3. Connect Using pgAdmin
    • Open pgAdmin.
    • Right-click Servers and select Create > Server.
    • Enter a name, e.g., azure-pg-tt.
    • On the Connection tab, enter the copied hostname and username from the Azure Portal.
    • Click Save to connect.


  4. Explore Created Databases
    • Expand the connected server in pgAdmin. You will see 3 databases pre-created by Azure. Do not delete these.
  5. Create a New Database to Use
    • Right-click Databases under your server, select Create > Database.
    • Name your new database, for example, mypgsqldb.
  6. Run SQL Queries on Your Database
    • Select your new database (mypgsqldb) and click the Query Tool icon in pgAdmin.
    • Run the following SQL commands to create a table, insert records, and query data:

sql

CREATE TABLE EMP(id serial PRIMARY KEY, name VARCHAR(50),  Salary INTEGER);

INSERT INTO EMP(id, name, salary) VALUES (1, 'Jon', 15000);

INSERT INTO EMP(id, name, salary) VALUES (2, 'Doe', 15400);

SELECT * FROM EMP;



You are now connected to the PostgreSQL database on Azure !!!!!!

No comments:

Post a Comment

Sample Text

Sample text