PostgreSQL Create Table


Initiate Connection

Before defining a structure for saving entries, ensure that you're linked to the proper PostgreSQL instance. Please revisit the original setup instructions to address the detected disconnection issue.


Structure Declaration

To initiate a storage object labeled vehicles, input the following directive:

CREATE TABLE vehicles (   
    make TEXT,   
    variant TEXT,   
    manufacture_year INTEGER 
); 

Running this command sets up an unfilled entity named vehicles. The terminal should indicate success via:

CREATE TABLE

Command Breakdown

This instruction generates a new repository consisting of three attributes: make, variant, and manufacture_year.

Each column demands a defined value type:

  • For make and variant, textual content is anticipated. TEXT permits character strings of indefinite span.
  • The field manufacture_year requires whole numbers, therefore INTEGER is used.

Review Schema

To visualize the newly built structure, execute:

SELECT * FROM vehicles;

Expected outcome:

make | variant | manufacture_year
 ------+---------+------------------ 
(0 rows)

Summary

At this stage, you've built a blank framework. Following topics will guide through populating records and retrieving stored values efficiently.


Prefer Learning by Watching?

Watch these YouTube tutorials to understand POSTGRESQL Tutorial visually:

What You'll Learn:
  • 📌 How To Create Table in Postgresql
  • 📌 03 How to create table in PostgreSQL
Previous Next