- 创建表如下:
CREATE TABLE "HOTEL3"
( "NAMEX" VARCHAR2(4000 CHAR),
"CITY" VARCHAR2(4000 CHAR),
"PRICE" NUMBER,
"ID" VARCHAR2(50 BYTE) DEFAULT sys_guid()
);
- 创建索引如下:
CREATE INDEX "IDX_HOTEL3_CITY_NAME" ON "HOTEL3" ("CITY" ASC, "NAMEX" DESC);
- 查询索引信息:
SELECT *
FROM all_ind_columns ic
WHERE ic.index_owner = 'FOO'
AND ic.table_name = 'HOTEL3'
ORDER BY ic.column_position;
我得到以下结果(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",
观察第二条记录;COLUMN_NAME
是SYS_NC00005$
代替NAMEX
.
以下是一些旁注。在第 1 步之后,如果您查询,all_tab_cols
您将获得所有 4 列。但是,在步骤 #2 之后,all_tab_cols
现在有一个附加条目 - 与上面的查询结果显示的名称相同。这可能有些牵强;但ID
已设置的字段DEFAULT
可能就是为什么在步骤 #2 之后all_tab_cols
有那个奇怪的条目。
那么我可以发出什么查询来获取正确的索引信息呢?
PS:我猜oracle服务器是19c。