Open In App

How to Create Tables on Heroku Postgresql

Last Updated : 30 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Heroku is a Platform as a Service (PaaS) used by developers to deploy their projects with different other requirements provided by the platform like database and all, whereas PostgreSQL is an open-source object-relational database system used for database management in many projects.

This article is going to show you how to create a table in Heroku PostgreSQL. 

We are going to use the following technologies in this article:

  • Heroku
  • PostgreSQL
  • Table Plus

Please note that this article assumes you to have a basic understanding of SQL queries and requires you to have a Heroku account.

Setting Up Heroku PostgreSQL

Follow the next given steps for setting up Heroku PostgreSQL:

Step 1: Log in to your Heroku account. If you do not have a Heroku account, create one and log in.

login of Heroku

login of Heroku

Step 2: After logging in, click on the ‘New’ button on the top right corner of the page as shown in the image below:

Interface after login

Interface after login

Step 3: Then create a new app with a unique app name of your own.

New app interface

New app interface 

Step 4: After the successful creation of the app, go to the resource tab as shown below:

Interface after creating an app

Interface after creating an app

Step 5: Search for Postgres in the add-on section and select the option titled ‘Heroku Postgres’ from the results

Option for add-on

Option for add-on

Submit the order form and move to the next step.

Step 6: Now, click on the ‘Heroku Postgres’ link that has now appeared on the screen.

Heroku Postgres link

Heroku Postgres link

Step 7: Click on the settings tab and then click on view credentials. This step includes settings related to the Heroku Postgres.

Settings tab

Settings tab 

After that, you can see an interface similar to the one shown below, click on view credential.

View Credentials

View Credentials

Step 8: Now we can see the credentials required to complete our task there are also other credentials provided for further use. Copy the URI credential for the next step given below.

URI credential

URI credential

Connecting to Heroku Postgresql using TablePlus 

TablePlus is a database management tool that provides a simple and easy-to-use GUI for creating tables and other queries of SQL to manage databases in an efficient manner.

Step 1: Open TablePlus and click on the ‘Create a new connection….’ option as shown in the GUI image.

TablePlus GUI

TablePlus GUI

Step 2: Now, get an interface similar to the image given below. Click on Import from URL For the next step of our task.  

Options for database

Options for database 

Step 3: Now paste the URL credential we copied earlier and click on the import button.

Import URL interface

Import URL interface 

Note: There is a line break in the copied URL so hit the delete key once to remove that break in the copied URL and then click on import.

Step 4: Now provide a suitable name to your database check all provided details and then click on the test button given below.

Create database and test

Create database and test 

If all fields are correctly filled it will show green marks on fields then click on save and move towards the next step.

Step 5: Now double-click on the database that we created earlier and is now visible on the TablePlus Dashboard

Database

Database 

Creating a table 

Step 1: Now we can see the Dashboard of TablePlus where we can now finally create our table in Heroku Postgres.

Table Plus GUI  dashboard

Table Plus GUI  dashboard

Step 2: Now in the left corner, we get two options: functions & tables.

Click on Tables -> New -> Table to create a table.

Table creation

Table creation 

Step 3: Now click on the option shown in the image below to create tables.

Creating the table

Creating the table

Finally, our table has been created successfully you can change or add any of the constraints for the table regarding to the use of that particular table in projects you can also perform various operations on the table.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads