- Creating a table as follows:
CREATE TABLE "HOTEL3"
( "NAMEX" VARCHAR2(4000 CHAR),
"CITY" VARCHAR2(4000 CHAR),
"PRICE" NUMBER,
"ID" VARCHAR2(50 BYTE) DEFAULT sys_guid()
);
- Creating an index as follows:
CREATE INDEX "IDX_HOTEL3_CITY_NAME" ON "HOTEL3" ("CITY" ASC, "NAMEX" DESC);
- Querying the index information:
SELECT *
FROM all_ind_columns ic
WHERE ic.index_owner = 'FOO'
AND ic.table_name = 'HOTEL3'
ORDER BY ic.column_position;
I am getting the below result (csv)
"INDEX_OWNER","INDEX_NAME","TABLE_OWNER","TABLE_NAME","COLUMN_NAME","COLUMN_POSITION","COLUMN_LENGTH","CHAR_LENGTH","DESCEND","COLLATED_COLUMN_ID"
"FOO","IDX_HOTEL3_CITY_NAME","FOO","HOTEL3","CITY",1,4000,4000,"ASC",
"FOO","IDX_HOTEL3_CITY_NAME","FOO","HOTEL3","SYS_NC00005$",2,2000,0,"DESC",
Observe the second record; COLUMN_NAME
is SYS_NC00005$
instead of NAMEX
.
Here are a few side notes. After step #1 if you query all_tab_cols
you get all 4 columns. However, after step #2, all_tab_cols
now has an additional entry - the same name as shown above query result. This could be far-fetched; but the ID
field having DEFAULT
set may be why, after step #2, all_tab_cols
has that strange entry.
So what query can I issue to get the correct index information?
PS: oracle server is 19c I guess.