[Redshift] How to find table ID associated with DDL statement

0

How can I find the table id modified by a DDL statement in Redshift? STL_DDLTEXT doesn't have a column associated with table id. Any help would be appreciated.

demandé il y a un an318 vues
1 réponse
0

from https://medium.com/@alex_handley/aws-redshift-handy-query-to-get-all-table-create-statements-for-a-schema-fcc0eaac03c1 something like the following should provide that information. Note that user generated schema's are not in pg_table_def search path by default

SET SEARCH_PATH TO <something>;

SELECT ddl FROM admin.v_generate_tbl_ddl JOIN pg_table_def ON ( admin.v_generate_tbl_ddl.schemaname = pg_table_def.schemaname AND admin.v_generate_tbl_ddl.tablename = pg_table_def.tablename ) WHERE admin.v_generate_tbl_ddl.schemaname = '<something>' GROUP BY admin.v_generate_tbl_ddl.tablename, ddl, "seq" ORDER BY admin.v_generate_tbl_ddl.tablename ASC, "seq" ASC;

from https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_generate_tbl_ddl.sql will provide you with detailed table information including distkey, sortkey, constraints, not null, defaults, etc.

profile picture
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions