Advertisement
ExaGridDba

create primary key on top of nonunique index

Dec 29th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. cat pk.on.nonunique.index.sql
  2. drop table nonunique purge;
  3. create table nonunique ( i number );
  4. create index pk_i on nonunique ( i );
  5. alter table nonunique add constraint pk_i primary key ( i );
  6. @ sel.pkdemo.md.sql NONUNIQUE
  7.  
  8. SQL> @ pk.on.nonunique.index.sql
  9.  
  10. Table dropped.
  11.  
  12.  
  13. Table created.
  14.  
  15.  
  16. Index created.
  17.  
  18.  
  19. Table altered.
  20.  
  21.  
  22. TABLE_NAME COLUMN_NAME NUL
  23. ------------------------------ ------------------------------ ---
  24. NONUNIQUE I N
  25.  
  26.  
  27. TABLE_NAME INDEX_NAME UNIQUENESS STATUS
  28. ------------------------------ ------------------------------ --------------------------- ------------------------
  29. NONUNIQUE PK_I NONUNIQUE VALID
  30.  
  31.  
  32. TABLE_NAME INDEX_NAME COLUMN_NAME
  33. ------------------------------ ------------------------------ ------------------------------
  34. NONUNIQUE PK_I I
  35.  
  36.  
  37. CONSTRAINT_NAME CON STATUS VALIDATED
  38. ------------------------------ --- ------------------------ ---------------------------------------
  39. PK_I P ENABLED VALIDATED
  40.  
  41. You can create a primary key constraint on top of a nonunique index.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement