PostgreSQL Add Column


Expanding a Table’s Structure

To insert a fresh field into an already-built dataset, we use the ALTER TABLE command.

This instruction lets us introduce new attributes, eliminate existing ones, or revise the configuration of columns in the same structure.

It can also be applied to manage settings like keys, rules, or column conditions.


Attach a New Field

Let’s say we aim to include a field labeled shade in the autos table.

While introducing a new attribute, you must indicate what kind of data it will contain. Since shade is descriptive text, we’ll use VARCHAR and limit it to 255 characters.


Instruction Example

ALTER TABLE autos   
ADD shade VARCHAR(255); 

Outcome

ALTER TABLE

→ Confirms the table has been modified successfully.


Review Changes

To view the modified structure, run this:

SELECT * FROM autos;

You’ll now notice a fresh column named shade has been added.

At this point, the field has no entries—updating it with values will be covered in the next step.


Prefer Learning by Watching?

Watch these YouTube tutorials to understand POSTGRESQL Tutorial visually:

What You'll Learn:
  • 📌 How to add a new column in PostgreSQL | Add column in PostgreSQL
  • 📌 How To Add New Column To Table in Postgresql
Previous Next