我建立了一个零时表:
CREATE GLOBAL TEMPORARY TABLE test_temp (COL1 VARCHAR2(10),
COL2 VARCHAR2(10)
) ON COMMIT preserve ROWS;
然后写了个procedure 给前台调用(java)
create or replace procedure test_prc_temp(v_col1 varchar2,v_col2 varchar2) as
v_num number;
begin
--insert data
insert into test_temp values (v_col1,v_col2);
insert into test_temp values (v_col1,v_col2);
insert into test_temp values (v_col1,v_col2);select count(1) into v_num from test_temp;
dbms_output.put_line(v_num);
--execute immediate 'delete from test_temp';
end ;++++++++++++++++++
我在前台运行select count(*) from test_temp, 能返回3. (同一个connection中)
但我运行select col1,col2 form test_temp,却没有数据,这是为什么???
CREATE GLOBAL TEMPORARY TABLE test_temp (COL1 VARCHAR2(10),
COL2 VARCHAR2(10)
) ON COMMIT preserve ROWS;
然后写了个procedure 给前台调用(java)
create or replace procedure test_prc_temp(v_col1 varchar2,v_col2 varchar2) as
v_num number;
begin
--insert data
insert into test_temp values (v_col1,v_col2);
insert into test_temp values (v_col1,v_col2);
insert into test_temp values (v_col1,v_col2);select count(1) into v_num from test_temp;
dbms_output.put_line(v_num);
--execute immediate 'delete from test_temp';
end ;++++++++++++++++++
我在前台运行select count(*) from test_temp, 能返回3. (同一个connection中)
但我运行select col1,col2 form test_temp,却没有数据,这是为什么???
select count(*) from test_temp
这两天语句是在同一个连接中执行的么
基于session 的临时表在连接断开的时候会执行截断(truncate)操作的
CREATE GLOBAL TEMPORARY TABLE test_temp (COL1 VARCHAR2(10),
COL2 VARCHAR2(10)
) ON COMMIT preserve ROWS
insert into test_temp values ('aa','bb');
insert into test_temp values ('aaa','bbb');
insert into test_temp values ('aaaa','bbbb');select *--count(*)
from test_temp结果能选出:
aa, bb
aaa, bbb
aaaa, bbbb
GLOBAL TEMPORARY TABLE 在连接断开或session转换都会自动删掉。
GLOBAL代表这个表结构是全局的,但是不同的session的数据是互不可见的。
GLOBAL代表这个表结构是全局的,但是不同的session的数据是互不可见的。
我可以差出数据了. 错误是我的一个表名写错了:(