How to Remove a Primary Key in SQL Database: Standard SQL MySQL PostgreSQL Oracle MS SQL Server Operators: DROP CONSTRAINT DROP PRIMARY KEY ALTER TABLE Table of Contents Problem: Example: Solution 1: Discussion: Solution 2 (dropping the primary key constraint): Discussion: Problem: You want to drop a primary key from a table in a database. Example: We want to remove the primary key from the table product. Solution 1: ALTER TABLE product DROP PRIMARY KEY; Discussion: To drop a primary key from a table, use an ALTER TABLE clause with the name of the table (in our example, product) followed by the clause DROP PRIMARY KEY. Since a table can have only one primary key, you don’t need to specify the primary key column(s). Solution 2 (dropping the primary key constraint): ALTER TABLE product DROP CONSTRAINT PK_product_id; Discussion: Another way is to use ALTER TABLE with the DROP CONSTRAINT clause with the name of the primary key constraint. This is a good way to remove the primary key if you know the name of the primary key constraint. However, you must specify the name of the primary key constraint. Recommended courses: The Basics of Creating Tables Data Types in SQL SQL Constraints Recommended articles: SQL Basics Cheat Sheet What is a Primary Key in SQL? Why Use Primary Keys and Foreign Keys in Databases? How to Create a Table in SQL Understanding Numerical Data Types in SQL See also: How to Create a Primary Key in SQL How to Delete a Foreign Key Constraint in SQL How to Find the Name of a Constraint in MySQL How to Find the Name of a Constraint in Oracle How to Find the Name of a Constraint in PostgreSQL How to Find the Name of a Constraint in SQL Server Subscribe to our newsletter Join our monthly newsletter to be notified about the latest posts. Email address How Do You Write a SELECT Statement in SQL? What Is a Foreign Key in SQL? Enumerate and Explain All the Basic Elements of an SQL Query