Add a new primary key in the table

kartik goyal
Dec 9, 2023

--

Following steps to be followed.

  1. Create a duplicate table containing all the required columns and a new primary key column.

2. Use query insert into duplicate_table_name (…) select (…) from table_name (use order by optional)

3. Now Rename table_name — table_name_backup & duplicate_table_name — table_name

4. We have added a new primary key and preserved the data.

--

--

No responses yet