How to add a primary key to an existing table PostgreSQL

H

How Can We Help?

How to add a primary key to an existing table PostgreSQL

ALTER TABLE table ADD primary key (primary_key_id);

Replace table with your table name and primary_key_id with your Primary Key

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me