临时表:
create global tempORARY table test (
id number(8),
compname varchar2(20)
);insert into test (
select * from yourtable
);
create global tempORARY table test (
id number(8),
compname varchar2(20)
);insert into test (
select * from yourtable
);
1。会话特有的临时表
CREATE GLOBAL TEMPORARY <TABLE_NAME> (<column specification> )
ON COMMIT PRESERVE ROWS; 2。事务特有的临时表
CREATE GLOBAL TEMPORARY <TABLE_NAME> (<column specification> )
ON COMMIT DELETE ROWS;
CREATE GLOBAL TEMPORARY TABLE MyTempTable
所建的临时表虽然是存在的,但是你试一下insert 一条记录然后用别的连接登上去select,记录是空的,明白了吧。
下面两句话再贴一下:
--ON COMMIT DELETE ROWS 说明临时表是事务指定,每次提交后ORACLE将截断表(删除全部行)
--ON COMMIT PRESERVE ROWS 说明临时表是会话指定,当中断会话时ORACLE将截断表。
create table aaa(aaa,bbb,ccc)
create table bbb(ddd,eee,fff)
我想的创建临时表的字段是动态的。
也就是说,
select aaa 表的aaa,bbb后insert temptable.
再select temptable.最后用完后自动删除temptable的字段。
select aaa.bbb 表的aaa,eee后insert temptable.
再select temptable.最后用完后自动删除temptable的字段。请问怎样实现呀??
我觉得这点确实不如sql里的临时表用着方便。
临时表:
create global tempORARY table test (
id number(8),
compname varchar2(20)
);insert into test (
select * from yourtable
);
不是yourtable的字段,必须是id,compname,如果yourtable字段有n个,create table不是很麻
烦,有没有好的方法???