RefLib

Reference library for AI

Back

postgresql_16:3.2.6 Modifying Tables

PostgreSQL 16 > The SQL Language > Data Definition > Modifying Tables

When you create a table and you realize that you made a mistake, or the requirements of the application change, you can drop the table and create it again. But this is not a convenient option if the table is already filled with data, or if the table is referenced by other database objects (for instance a foreign key constraint). Therefore PostgreSQL provides a family of commands to make modifications to existing tables. Note that this is conceptually distinct from altering the data contained in the table: here we are interested in altering the definition, or structure, of the table.

You can: Add columns Remove columns Add constraints Remove constraints Change default values Change column data types Rename columns Rename tables All these actions are performed using the (see postgresql_16:7.1.33) command, whose reference page contains details beyond those given here.

Subsections

Back