postgreSQL的temporary table的删除机制

mz0827 发布于 2013/12/12 14:33
阅读 339
收藏 0

我创建了temporary table,看官方资料:

TEMPORARY or TEMP

If specified, the table is created as a temporary table. Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction

怎么理解“ Temporary tables are automatically dropped at the end of a session”中的这个session啊?

我现在把connection close掉,temporary table 不会自动删除。

加载中
0
kenyon_君羊
kenyon_君羊
你的数据库什么版本啊,我的测试
[postgres@localhost ~]$ psql
psql (9.1.4)
Type "help" for help.

postgres=# \d
No relations found.
postgres=# create temp table kenyon(id int);
CREATE TABLE
postgres=# insert into kenyon select generate_series(1,10);
INSERT 0 10
postgres=# select count(1) from kenyon;
 count 
-------
    10
(1 row)

postgres=# \d+
                         List of relations
   Schema   |  Name  | Type  |  Owner   |    Size    | Description 
------------+--------+-------+----------+------------+-------------
 pg_temp_29 | kenyon | table | postgres | 8192 bytes | 
(1 row)

postgres=# \q
[postgres@localhost ~]$ psql
psql (9.1.4)
Type "help" for help.

postgres=# \d
No relations found.
postgres=#
返回顶部
顶部