How to get the ddl of an external table in Redshift database

Run the below query to obtain the ddl of an external table in Redshift database.

SELECT * FROM admin.v_generate_external_tbl_ddl WHERE schemaname = 'external-schema-name' and tablename='nameoftable';

If the view v_generate_external_tbl_ddl is not in your admin schema, you can create it using below sql provided by the AWS Redshift team.

https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_generate_external_tbl_ddl.sql

See also  How to move EBS volume to a different EC2 Instance across availability zones