Any way to find the original query that created a table?

Tools & Utilities

Any way to find the original query that created a table?

Hi everyone,

Is there a quick way to find the query used to create a table in SQL Assistant? Not the SHOW TABLE function, but a function to recreate the original query?

3 REPLIES
Teradata Employee

Re: Any way to find the original query that created a table?

select requestText
from dbc.tables
where tablename='tablename'
and databasename='databasename'
;

Keep in mind that on this way if you modified a table with "Alter table ..." you'll get this alter table request, and not the original create 

Junior Contributor

Re: Any way to find the original query that created a table?

Or you check the CreatorName & CreateTimestamp and try to find the query in the QueryLog history

Re: Any way to find the original query that created a table?

Thanks for the tips, guys. Very useful!