Site icon Database Tutorials

Add Primary Key To A Column In A Table With Data

In today’s article, we will learn how to add a primary key to a column in a table containing data in an Oracle database.

If we want to add a primary key to a column of a table with data and we get an error, the following process is followed.

1. We create a new table from the table to which the Primary Key will be added.

2. We Truncate the table to which the Primary Key will be added.

3. Now we add a Primary Key to the table to which the Primary Key will be added.

4. We insert data from the newly created table into the original table.

Exit mobile version