PostgreSQL(Alternations)

Published: (March 20, 2026 at 05:12 AM EDT)
1 min read
Source: Dev.to

Source: Dev.to


⚠️ Collection Error: Content refinement error: Error: 429 429 Too Many Requests: you (bkperio) have reached your weekly usage limit, upgrade for higher limits: https://ollama.com/upgrade


Cover image for PostgreSQL(Alternations)

              [![s mathavi](https://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3250662%2Fc02e860f-3eda-41e7-a98f-3f6dcb800874.jpg)](https://dev.to/s_mathavi_2fa1e3ea8514f34)
              
              
            
      

      
            -ALTER TABLE → modify existing table structure.

-Operations: add/drop column, change datatype, rename column/table, add/drop constraints.

Common ALTER TABLE Operations

1. Add a new column

ALTER TABLE Employee

ADD COLUMN email VARCHAR(100);

2. Drop (remove) a column

ALTER TABLE Employee

DROP COLUMN email;

3. Change datatype of a column

ALTER TABLE Employee

ALTER COLUMN salary TYPE NUMERIC(12,2);

4. Rename a column

ALTER TABLE Employee

RENAME COLUMN name TO full_name;

5. Add a constraint

ALTER TABLE Employee

ADD CONSTRAINT salary_positive CHECK (salary > 0);

6. Drop a constraint

ALTER TABLE Employee

DROP CONSTRAINT salary_positive;

7. Rename the table itself

ALTER TABLE Employee

RENAME TO Staff;

This is the basic PostgreSQL…

See you soon in the next blog!…

0 views
Back to Blog

Related posts

Read more »