表情報を取得するビュー
Oracle では表情報はビュー ALL_TABLES
にある。
一時表に関連するカラムは以下
TABLESPACE_NAME
Name of the tablespace containing the table; null for partitioned, temporary, and index-organized tables
TEMPORARY
Can the current session only see data that it place in this object itself?
DURATION
Indicates the duration of a temporary table:
SYS$SESSION: the rows are preserved for the duration of the session
SYS$TRANSACTION: the rows are deleted after COMMIT
Null for a permanent table
出力例
“ON COMMIT DELETE ROWS
” で作成した一時表の出力例
temporary = 'y'
で SELECT すると一覧を取得できる
SELECT table_name, tablespace_name, temporary, duration FROM user_tables WHERE temporary = 'y'; TABLE_NAME TABLESPACE_NAME T DURATION ------------------------------ ------------------------------ - --------------- TMP_TBL Y SYS$TRANSACTION
マニュアルどおり
TABLESPACE_NAME
はブランクT(TEMPORARY)
は ‘Y
‘DURATION
はSYS$TRANSACTION
となっている。
通常の表の出力例
TABLE_NAME TABLESPACE_NAME T DURATION ------------------------------ ------------------------------ - --------------- NML_TBL USERS N
マニュアルどおり
TABLESPACE_NAME
はUSERS
T(TEMPORARY)
は ‘N
‘DURATION
は ブランク
となっている。
ALL_TABLE/DBA_TABLE/USER_TABLEの違い
これら3つは表示するカラムは同じだけど、表示対象の表が異なる。
マニュアル ALL_TABLES の項の先頭に違いについて説明がある。
ALL_TABLES
describes the relational tables accessible to the current userDBA_TABLES
describes all relational tables in the database.USER_TABLES
describes the relational tables owned by the current user. This view does not display the OWNER column.
References
- StackOverflow : Check to see if a Temporary Table exists
http://stackoverflow.com/questions/8156784/check-to-see-if-a-temporary-table-exists - Oracle の各 CREATE TABLE 文のマニュアル
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm - Oracle の ALL_TABLES ビューのマニュアル
http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2105.htm - ASK TOM : 一時テーブルの使用例
http://asktom.oracle.com/pls/asktom/f?p=100:11:0%3a%3a%3a%3aP11_QUESTION_ID:48812348054
参考になりました~
ちなみに
× temporary = ‘y’で SELECT すると一覧を取得できる
○ temporary = ‘Y’で ~~
でした