Reputation: 377
Is there a way that I can extract the DDL of all the tables in one single query.
select DatabaseName,TableName,RequestText from db.tables;
gives the database name , table name and the last DDL on the table. But is it possible to get DDL to create the tables in form of resultset to a query instead of querying show db.tableName several times
Upvotes: 0
Views: 6898
Reputation: 172448
You can try this:
sel 'show table ' || databasename ||'.'|| tablename ||';'
from dbc.tables where databasename = 'dbname' and tablekind = 'T';
and then you can execute the output of this query to get the DDL like:
show table dbname.sometablename;
Upvotes: 1