1的错应该是语法错,你是不是在什么地方丢了分号或别的什么
2的错是这样,temp_table的类型是一提交就删除数据,而create global temporary table temp_table on commit delete rows as select * from tablename创建表的时候就插入数据并且马上提交,在我这里执行这条语句时会报个错ora-25153 temporary tablespace is empty,并且表也建不起来解决办法是
create global temporary table temp_table on commit delete rows as
select * from tablename where 1=2;
这样只建表不插入记录
2的错是这样,temp_table的类型是一提交就删除数据,而create global temporary table temp_table on commit delete rows as select * from tablename创建表的时候就插入数据并且马上提交,在我这里执行这条语句时会报个错ora-25153 temporary tablespace is empty,并且表也建不起来解决办法是
create global temporary table temp_table on commit delete rows as
select * from tablename where 1=2;
这样只建表不插入记录
解决方案 »
- 请教一个关于Oracle中两个不同数据库中的表的对比问题
- ORACLE数据库运行一段时间后(一个星期左右),登陆总是出现"ora-12560错误,TNS:协议适配器错误"。
- oracle 中如何计算当前日期加三个工作日?(星期一到星期五为工作日)
- 自动启动/关闭数据库
- plsql developer使用一问
- OracleOraDb10g_home1iSQL*Plus 服务无法启动
- 百分请教,with子句可以用在Oracle存储过程中吗
- 机器更名后,oracle9i无法启动
- 在线等:ORA-04031是什么问题怎么解决?
- 请问oralce有监视SQL语句的工具吗?
- 分不在多,心成则灵!请问何种权限的用户才能够从登陆 oracle dba studio登陆? help!
- 请教ORA-03113的解决
我仔细检查了第一种方法,没发现语法错误
第二种方法今天再试,提示PLS-00201,必须说明标识符‘temp_table'
很奇怪
create_sql := 'create global temporary table temp_table on commit delete rows as select * from tablename' ;
execute immediate create_sql ;
也应该放在存储过程或匿名块中执行,你是怎么执行的?把完整的帖出来看看.你的数据库版本 是多少,我是在9i里试的没问题
在oracle 中执行的。第一个如下:
create or replace procedure temporary_table_test
is
create_sql varchar2(500) ;
create_sql := 'create global temporary table temp_table on commit delete rows as select * from tablename' ;
execute immediate create_sql ; 第二个如下:
create or replace procedure temporary_table_test
is
create_sql varchar2(50) ;
source_cursor integer ;
install_lan_E1A integer ;
begin
begin
create_sql := 'create global temporary table temp_table on commit delete rows as select * from tablename where 1= 2' ;
source_cursor := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(source_cursor, create_sql, DBMS_SQL.native);
select count(*) into install_lan_E1A from temp_table ; DBMS_SQL.CLOSE_CURSOR(source_cursor);
end ;
end temporary_table_test;
is
create_sql varchar2(500) ;
begin --原文中缺了
create_sql := 'create global temporary table temp_table on commit delete rows as select * from tablename' ;
execute immediate create_sql ;
end; --原文中缺了但是不知道7.3支持不支持临时表?
数据库是7.3不支持execute immediate
问题二:
动态创建临时表,与表空间有关系,两种方案1、本地+临时,2、字典+永久
PERMANENT
Specify PERMANENT if the tablespace will be used to hold permanent objects. This is the default.
TEMPORARY
Specify TEMPORARY if the tablespace will be used only to hold temporary objects, for example, segments used by implicit sorts to handle ORDER BY clauses. Restriction: If you specify TEMPORARY, you cannot specify EXTENT MANAGEMENT LOCAL.
DICTIONARY
Specify DICTIONARY if you want the tablespace to be managed using dictionary tables. This is the default.
LOCAL
Specify LOCAL if you want the tablespace to be locally managed. Locally managed tablespaces have some part of the tablespace set aside for a bitmap.
1、DICTIONARY+PERMANENT 2、LOCAL+TEMPORARY
参考:http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a85397/statem4c.htm#2063129