oracle 在全局临时表上创建索引
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34946353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create index on Global temporary table
提问by Yoga
Is it possible to create index on Global temporary table? If Yes, Do we need to create in a single session.
是否可以在全局临时表上创建索引?如果是,我们是否需要在单个会话中创建。
I tried the following way and ended up with the below issue.
我尝试了以下方法并最终解决了以下问题。
Session 1:
第 1 节:
CREATE GLOBAL TEMPORARY TABLE "SFE_ADM"."DUMMY_GLO"
( "C1" VARCHAR2(6 CHAR)
) ON COMMIT PRESERVE ROWS ;
CREATE INDEX DUMMY_GLO_IDX ON DUMMY_GLO (C1) TABLESPACE SFE_I1;
Session 1:
第 1 节:
CREATE GLOBAL TEMPORARY TABLE "SFE_ADM"."DUMMY_GLO"
( "C1" VARCHAR2(6 CHAR)
) ON COMMIT PRESERVE ROWS ;
Session 2:
第 2 节:
CREATE INDEX DUMMY_GLO_IDX ON DUMMY_GLO (C1) TABLESPACE SFE_I1;
Session 1:
第 1 节:
CREATE GLOBAL TEMPORARY TABLE "SFE_ADM"."DUMMY_GLO"
( "C1" VARCHAR2(6 CHAR)
) ON COMMIT PRESERVE ROWS ;
Session 2:
第 2 节:
TRUNCATE TABLE DUMMY_GLO
CREATE INDEX DUMMY_GLO_IDX ON DUMMY_GLO (C1) TABLESPACE SFE_I1;
For all the above tries i got an error message saying.
对于上述所有尝试,我收到一条错误消息。
getting an error while creating index for temporary table
Error starting at line : 1 in command -
CREATE INDEX DUMMY_GLO_IND ON DUMMY_GLO (C1) TABLESPACE SFE_I1
Error at Command Line : 1 Column : 42
Error report -
SQL Error: ORA-14451: unsupported feature with temporary table
14451. 00000 - "unsupported feature with temporary table"
*Cause: An attempt was made to create an IOT, specify physical attributes,
specify partition or parallel clause.
*Action: do not do that
回答by Tony Andrews
Yes you can create an index on a temporary table, but you cannot specify a tablespace for it:
是的,您可以在临时表上创建索引,但不能为其指定表空间:
SQL> CREATE INDEX DUMMY_GLO_IDX ON DUMMY_GLO (C1);
Index created.
I'm not sure why you are trying to use different sessions. A global temporary table and its index are only to be created once, just like a normal table. Then many sessions can use the table at once, without seeing each other's data.
我不确定您为什么要尝试使用不同的会话。一个全局临时表及其索引只需创建一次,就像普通表一样。那么多个会话可以同时使用该表,而不会看到彼此的数据。