Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Redshift Script export

How can i save all redshift database ddl script into my local drive for my managing repository on bitbucket. It means that I want to export all ddl script from redshift database and want to save in same structure folder in local like databasename => tablename =>tablescript.sql

Thanks in advance

like image 904
Anuj Singh Avatar asked Dec 17 '25 13:12

Anuj Singh


1 Answers

The Redshift Utils project provides a view that you can use to generate DDL for tables, views, schemas, and functions. https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_generate_tbl_ddl.sql

Using psql periodically run this and check the output into version control:

psql -d my_database \
   --no-align --field-separator $'\t' \
   --pset footer=off -o all_table_ddl.sql \
   -c "SELECT ddl FROM admin.v_generate_tbl_ddl;"
like image 61
Joe Harris Avatar answered Dec 20 '25 08:12

Joe Harris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!