How to get the ddl of a view in Redshift database

DDL of views can be obtained from information_schema.views. Below is the sql to get the view definition where schemaname is the name of the schema and viewname is the name of the view.

select view_definition from information_schema.views where table_schema='schemaname' and table_name='viewname';
See also  Adding Comments to Tables and Columns in Redshift database