Name already been used by an existing constraint after renaming the table and creating a new one

oracle-11g

I would like to know why, if I alter a table name to different name and then create a table with the same name, I am getting the error "name already been used by existing constraint".

This is the create table code

   create table abc
  (
       num number (4),
       name varchar2 (50),
      constraint abc primary key (num, name)
 );

This is the alter table code

 alter table abc rename to cba;

This is the code to recreate the table

   create table abc
  (
       num number (4),
       name varchar2 (50),
      constraint abc primary key (num, name)
 );

Best Answer

After renaming the table, rename the constraint and the index as well:

alter table cba rename constraint abc to cba;
alter index abc rename to cba;