Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sql_template="CREATE TABLE new_table (LIKE history INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES);
- SELECT create_hypertable('new_table', 'time', chunk_time_interval => interval ':day_num day', migrate_data => TRUE );
- INSERT INTO new_table SELECT * FROM :table_name;
- DROP TABLE :table_name;
- ALTER TABLE new_table RENAME TO :table_name"
- declare -a sql_config=(("history" 2) ("history_uint" 2) ("trends" 14") ("trends_uint" 14))
- # proste pole poli, protoze bash nema asociativni pole (mapu)
- for config in sql_config; do
- sql=${sql_template/:table_one/$config[0]}
- sql=$(sql/:day_num/$config[1])
- psql -U user -d db -c sql
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement