1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1) ON COMMIT DELETE ROWS 定义了建立事务级临时表的方法. CREATE GLOBAL TEMPORARY TABLE admin_work_area (startdate DATE, enddate DATE, class CHAR(20)) ON COMMIT DELETE ROWS; EXAMPLE: SQL> CREATE GLOBAL TEMPORARY TABLE admin_work_area 2 (startdate DATE, 3 enddate DATE, 4 class CHAR(20)) 5 ON COMMIT DELETE ROWS; SQL> create table permernate( a number); SQL> insert into admin_work_area values(sysdate,sysdate,'temperary table'); SQL> insert into permernate values(1); SQL> commit; SQL> select * from admin_work_area; SQL> select * from permernate; A 1 2)ON COMMIT PRESERVE ROWS 定义了创建会话级临时表的方法. CREATE GLOBAL TEMPORARY TABLE admin_work_area (startdate DATE, enddate DATE, class CHAR(20)) ON COMMIT PRESERVE ROWS; EXAMPLE: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | SQL> drop table admin_work_area; SQL> CREATE GLOBAL TEMPORARY TABLE admin_work_area 2 (startdate DATE, 3 enddate DATE, 4 class CHAR(20)) 5 ON COMMIT PRESERVE ROWS; SQL> insert into permernate values(2); SQL> insert into admin_work_area values(sysdate,sysdate,'session temperary'); SQL> commit; SQL> select * from permernate; A ---------- 1 2 SQL> select * from admin_work_area; STARTDATE ENDDATE CLASS ---------- ---------- -------------------- 17-1?? -03 17-1?? -03 session temperary |
1 2 3 4 5 6 7 | SQL> select * from permernate; A ---------- 1 2 SQL> select * from admin_work_area; 未选择行. |
1 2 | CREATE TABLE #MyTempTable (cola INT PRIMARY KEY) INSERT INTO #MyTempTable VALUES (1) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | CREATE PROCEDURE Test2 AS CREATE TABLE #t(x INT PRIMARY KEY) INSERT INTO #t VALUES (2) SELECT Test2Col = x FROM #t GO CREATE PROCEDURE Test1 AS CREATE TABLE #t(x INT PRIMARY KEY) INSERT INTO #t VALUES (1) SELECT Test1Col = x FROM #t EXEC Test2 GO CREATE TABLE #t(x INT PRIMARY KEY) INSERT INTO #t VALUES (99) GO EXEC Test1 GO |
1 2 3 4 5 6 7 8 | (1 row(s) affected) Test1Col ----------- 1 (1 row(s) affected) Test2Col ----------- 2 |
欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://p.delit.cn/) | Powered by Discuz! X3.2 |