How to extract DDL from tables/views using a SQL query?

RichardSCarchit
New Contributor III

I want to write a SQL query that queries the information_schema to generate a list of objects, their columns, relationships etc. - basically a data dictionary.

For each object I want to show the DDL code, and I know I can get it by executing

show create table [tablename]

but this command only runs as standalone, not as subquery within DML.

I can't manually repeat 'show create table' for hundreds of tables each time, so is there a way to get to the object DDL within a SQL query? For example in Oracle I could use a subquery

SELECT DBMS_METADATA.get_ddl etc. etc.

Can't use Python for a number of reasons. Thanks for any suggestion!