Query below finds all views in all databases with their script.
Query
SELECT DatabaseName,
TableName AS ViewName,
RequestText AS Definition
FROM DBC.TablesV
WHERE TableKind = 'V'
AND DatabaseName NOT IN ('All', 'Crashdumps', 'DBC', 'dbcmngr',
'Default', 'External_AP', 'EXTUSER', 'LockLogShredder', 'PUBLIC', 'SQLJ',
'Sys_Calendar', 'SysAdmin', 'SYSBAR', 'SYSJDBC', 'SYSLIB', 'SYSSPATIAL',
'SystemFe', 'SYSUDTLIB', 'SYSUIF', 'TD_SERVER_DB', 'TD_SYSFNLIB',
'TD_SYSGPL', 'TD_SYSXML', 'TDMaps', 'TDPUSER', 'TDQCD', 'TDStats', 'tdwm')
ORDER BY DatabaseName,
ViewName;
Columns
- DatabaseName - database name
- ViewName - view name
- Definition - definition (script) of the view
Rows
- One row represents a view
- Scope of rows: all found views
- Ordered by database & view name
Notes
Query excludes system databases, but this list may not be complete as it depends on the Teradata Database configuration.