This quickstart shows how to use Azure Data Studio to connect to PostgreSQL, and then use SQL statements to create the database tutorialdb and query it.
Prerequisites
To complete this quickstart, you need Azure Data Studio, the PostgreSQL extension for Azure Data Studio, and access to a PostgreSQL server.
The first time you start Azure Data Studio the Connection dialog opens. If the Connection dialog doesn't open, select the New Connection icon in the SERVERS page:
In the form that pops up, go to Connection type and select PostgreSQL from the drop-down.
Fill in the remaining fields using the server name, user name, and password for your PostgreSQL server.
Setting
Example value
Description
Server name
localhost
The fully qualified server name
User name
postgres
The user name you want to sign in with.
Password (SQL Login)
password
The password for the account you're logging in with.
Password
Check
Check this box if you don't want to enter the password each time you connect.
Database name
<Default>
Fill this if you want the connection to specify a database.
Server group
<Default>
This option lets you assign this connection to a specific server group you create.
Name (optional)
leave blank
This option lets you specify a friendly name for your server.
Select Connect.
After successfully connecting, your server opens in the SERVERS sidebar.
The following steps create a database named tutorialdb:
Right-click on your PostgreSQL server in the SERVERS sidebar and select New Query.
Paste this SQL statement in the query editor that opens up.
SQL
CREATEDATABASE tutorialdb;
From the toolbar select Run to execute the query. Notifications appear in the MESSAGES pane to show query progress.
Tip
You can use F5 on your keyboard to execute the statement instead of using Run.
After the query completes, right-click Databases, and select Refresh to see tutorialdb in the list under the Databases node.
Create a table
The following steps create a table in the tutorialdb:
Change the connection context to tutorialdb using the drop-down in the query editor.
Paste the following SQL statement into the query editor and select Run.
Note
You can either append this or overwrite the existing query in the editor. Selecting Run executes only the query that is highlighted. If nothing is highlighted, selecting Run executes all queries in the editor.
SQL
-- Drop the table if it already existsDROPTABLEIFEXISTS customers;
-- Create a new table called 'customers'CREATETABLE customers(
customer_id SERIAL PRIMARY KEY,
nameVARCHAR (50) NOTNULL,
location VARCHAR (50) NOTNULL,
email VARCHAR (50) NOTNULL
);
Insert rows
Paste the following snippet into the query window and select Run:
Azure Database for PostgreSQL is a Platform as a Service database service in the Microsoft cloud. It bases itself on the PostgreSQL open-source relational database and includes built-in high availability, automatic backup and restore, as well as comprehensive security features. The pay-as-you-go pricing model provides predictable performance and near-instant scaling. In this learning path, you're introduced to the main features of PostgreSQL and how they work in Azure Database for PostgreSQL. You learn abou
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.