#4 Oracle PrimaryKeys in wrong order for some tables

open
Mike.Griffin
None
5
2007-07-26
2007-07-22
No

This applies to Oracle 9i and 10g for tables with composite primary keys. Columns and indexes are listed in the same order as the table SQL, but primarykeys appear to be listed alphabetically. This causes them to be swapped for some tables. Looking at MyMeta Browser for the table below:

Columns
- B
- A

PrimaryKeys
- A
- B

-- Create table
create table tb_test
(
b NUMBER(18) not null,
a NUMBER(10) not null
);
-- Create/Recreate primary, unique and foreign key constraints
alter table tb_test
add constraint tb_test primary key (b, a)
using index ;

Discussion

  • komma8.komma1
    komma8.komma1
    2007-07-26

    • assigned_to: nobody --> thegriftster