Hello Exasol,
Is there a way to check for invalid views in Exasol — specifically, views that reference non-existing objects?
I’d like to identify any broken or outdated views in the database. Thanks in advance for your help!
Hello Exasol,
Is there a way to check for invalid views in Exasol — specifically, views that reference non-existing objects?
I’d like to identify any broken or outdated views in the database. Thanks in advance for your help!
Hello,
You can figure out whether views are invalid by looking at whether there are EXA_ALL_COLUMNS
rows defined for them. An invalid view will either have no columns in that table or the column’s STATUS field will be “OUTDATED”. However, there are 2 scenarios where EXA_ALL_COLUMNS
can be inaccurate:
EXA_ALL_COLUMNS
will not contain rows for the view regardless of whether the view is valid or not until it is accessed for the first time.EXA_ALL_COLUMNS
will contain rows for it even but the STATUS column will read ‘OUTDATED’ (regardless of whether the view is still valid or not).To make sure EXA_ALL_COLUMNS
is accurate you have to first access any view that falls under these two scenarios and then check again. The query below will also show invalid system views, based on EXA_SYS_COLUMNS
. So the procedure is:
SELECT *
FROM (
SELECT view_schema,
view_name
FROM exa_all_views v
LEFT JOIN exa_all_columns c
ON v.view_schema = c.column_schema
AND v.view_name = c.column_table
GROUP BY view_schema, view_name
HAVING ANY( column_name IS NULL )
OR ANY( status = 'OUTDATED' )
UNION ALL
SELECT
column_schema,
column_table
FROM
exa_sys_columns c
WHERE
status = 'OUTDATED'
GROUP BY
column_schema, column_table
)
ORDER BY 1, 2
;
DESC schema.view
. If this DESC fails the view is invalid and vice versa.Hope this will be helpful to you