How to Create Tables on Heroku Postgresql
Last Updated :
23 May, 2024
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 HerokuStep 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 loginStep 3: Then create a new app with a unique app name of your own.
New app interface Step 4: After the successful creation of the app, go to the resource tab as shown below:
Interface after creating an appStep 5: Search for Postgres in the add-on section and select the option titled 'Heroku Postgres' from the results
Option for add-onSubmit 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 linkStep 7: Click on the settings tab and then click on view credentials. This step includes settings related to the Heroku Postgres.
Settings tab After that, you can see an interface similar to the one shown below, click on view credential.
View CredentialsStep 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 credentialConnecting 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 GUIStep 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 Step 3: Now paste the URL credential we copied earlier and click on the import button.
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 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 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 Â dashboardStep 2: Now in the left corner, we get two options: functions & tables.
Click on Tables -> New -> Table to create a table.
Table creation Step 3: Now click on the option shown in the image below to create tables.
Creating the tableFinally, 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.
Similar Reads
PostgreSQL - CREATE TABLE In PostgreSQL, the CREATE TABLE statement is used to define a new table within a database. It allows us to specify the table's structure, including column names, data types, and constraints, ensuring data integrity and consistency. Understanding the PostgreSQL table creation process is essential for
5 min read
PostgreSQL - CREATE TABLESPACE In PostgreSQL, a tablespace is a mechanism used to map a logical name to a physical location on disk. Simply put, a tablespace is a disk location where PostgreSQL stores all its database objects, such as tables, indexes, and more. Understanding and utilizing tablespaces effectively can significantly
2 min read
PostgreSQL - Create Tables in Python Creating tables in PostgreSQL using Python is an essential skill for developers working with databases. This article will explore the process of creating new tables in the PostgreSQL database using Python.Why Create PostgreSQL Tables with Python?Using Python to create PostgreSQL tables is beneficial
4 min read
PostgreSQL - CREATE TABLE AS The CREATE TABLE AS statement in PostgreSQL is a powerful tool used to create a new table and populate it with data returned by a query. This functionality allows you to generate tables on the fly based on query results, which can be very useful for reporting, analysis, and other tasks.Let us better
3 min read
How to create Tables in Pug View Engine ? Pug is a template engine for NodeJS and browsers, enabling dynamic content rendering. It compiles templates to HTML, supports JavaScript expressions for formatting, and facilitates the reuse of static pages with dynamic data. Its indentation-based syntax simplifies tag specification, enhancing reada
3 min read