daily pastebin goal
26%
SHARE
TWEET

create primary key on top of nonunique index

ExaGridDba Dec 29th, 2016 (edited) 101 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top