Hello Janice,
You can use Global temporary tables for achieving this.
Global temporary table definitions are accessible to all users and sessions, so that two (or more) users can access the same global table concurrently. However, whenever a user commits or rolls back a transaction, or ends the session, Vertica removes the global temporary table data automatically, so users see only data specific to their own transactions or session.
Global temporary table definitions persist in the database catalogs until they are removed explicitly through a DROP TABLE statement.
If you are expecting the data to be present after opening a new session, then this will no suffice your requirement.
Temporary tables cannot hold data after a session is closed. they are session specific.
Code: Select all
nnani=> CREATE GLOBAL TEMPORARY GT_test
nnani-> (
nnani(> test_id int
nnani(> ,test_tab_name varchar(30)
nnani(> ,test_date date
nnani(> );
CREATE TABLE
nnani=> select * from GT_test;
test_id | test_tab_name | test_date
---------+---------------+-----------
(0 rows)
nnani=> insert into GT_test values(2,'global_temp','2013-10-01');
OUTPUT
--------
1
(1 row)
nnani=> commit;
COMMIT
nnani=> select * from GT_test;
test_id | test_tab_name | test_date
---------+---------------+-----------
(0 rows)
\q
Welcome to vsql, the Vertica Analytic Database interactive terminal.
Type: \h or \? for help with vsql commands
\g or terminate with semicolon to execute query
\q to quit
Bad terminal type: "xterm". Will assume vt100.
nnani=> select * from GT_test;
test_id | test_tab_name | test_date
---------+---------------+-----------
(0 rows)
nnani=> \d+ GT_test
List of Fields by Tables
Schema | Table | Column | Type | Size | Default | Not Null | Primary Key | Foreign Key
--------------------+---------+---------------+-------------+------+---------+----------+-------------+-------------
public| GT_test | test_id | int | 8 | | f | f |
public| GT_test | test_tab_name | varchar(30) | 30 | | f | f |
public| GT_test | test_date | date | 8 | | f | f |
(3 rows)
Using Global temporary tables you can have table structure persistent but data will be lost everytime.
Workaround - You can think of Views
Hope this helps..
