sql - create table with system date in Vertica -
i looking create table table like:
create table archive.postpaid_gsmis_`date +%y%m%d%h%m%s` ( select * postpaid.stage_gs10); commit;
wondering if can in vertica?
i thought of storing value in variable like:
\set x 'select now();' create table :x (int a);
but \echo :x
gives me select now();
.
see code bellow
dbadmin=> \set date `date +%y%m%d%h%m%s` dbadmin=> \echo :date 20170815112242 create table dba.postpaid_gsmis_:date select '1234' id dual ; create table dbadmin=> select * dba.postpaid_gsmis_:date; id ------ 1234 (1 row)
- is looking ?
append unix timestamp tablename:
dbadmin=> \set env `date +%s` dbadmin=> \echo :env 1502843933 dbadmin=> create table dba.tbl_:env (id int); create table dbadmin=> select * dba.tbl_1502843933; id ---- (0 rows)
also can build variable , use on table create
dbadmin=> \set var `var="blabla" && echo $var` dbadmin=> \echo :var blabla dbadmin=> create table dba.tbl_:var (id int); create table dbadmin=> select * dba.tbl_blabla; id ---- (0 rows)
Comments
Post a Comment