The order of my primary key columns appear to be in column name order, rather than the original order in my Oracle database.
See the following Oracle Create Table command, with the primary key column order PK1, PK3, and PK2:
CREATE TABLE "TESTSCHEMA"."TEST"
("PK2" VARCHAR2(20 BYTE) NOT NULL ENABLE,
"COL2" VARCHAR2(20 BYTE),
"COL3" VARCHAR2(20 BYTE),
"PK1" VARCHAR2(20 BYTE) NOT NULL ENABLE,
"PK3" VARCHAR2(30 BYTE) NOT NULL ENABLE,
CONSTRAINT "PK_TEST" PRIMARY KEY ("PK1", "PK3", "PK2")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ;
See the CDC Instance Deployment Script for the same table, noticing that the order of the primary key columns are now PK1, PK2, and PK3.
IF NOT EXISTS (SELECT 1 FROM [sys].[tables] WHERE SCHEMA_NAME([schema_id]) = N'TESTSCHEMA' AND [name]
= N'TEST')
CREATE TABLE [TESTSCHEMA].[TEST] (
[PK2] nvarchar(20),
[COL2] nvarchar(20),
[COL3] nvarchar(20),
[PK1] nvarchar(20),
[PK3] nvarchar(30),
CONSTRAINT [PK_TEST] PRIMARY KEY CLUSTERED (
PK1 ASC,
PK2 ASC,
PK3 ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
I ran the following, and got these results:
SELECT i.name AS index_name
,ic.index_column_id
,key_ordinal
,c.name AS column_name
,TYPE_NAME(c.user_type_id)AS column_type
,is_identity
FROM sys.indexes AS i
INNER JOIN sys.index_columns AS ic
ON i.object_id = ic.object_id AND i.index_id = ic.index_id
INNER JOIN sys.columns AS c
ON ic.object_id = c.object_id AND c.column_id = ic.column_id
WHERE i.is_primary_key = 1 and i.name = 'PK_TEST'
order by index_name, column_name
index_nameindex_column_idkey_ordinalcolumn_namecolumn_typeis_identityPK_TEST 2 3 PK1 nvarchar 0PK_TEST 1 2 PK2 nvarchar 0PK_TEST 3 1 PK3 nvarchar 0
This has to be a bug in CDC Designer. Can I hope for a quick fix?