How to tell if a table is referenced by a view?

Moderator: NorbertKrupa

Post Reply
beth
Intermediate
Intermediate
Posts: 58
Joined: Tue Oct 01, 2013 12:42 pm

How to tell if a table is referenced by a view?

Post by beth » Wed Apr 23, 2014 4:20 pm

Hi ,

I need to modify some tables (i.e. add columns). Is there as easy way that I can check if there are any objects (i.e. views) that reference a particular table?

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: How to tell if a table is referenced by a view?

Post by JimKnicely » Wed Apr 23, 2014 8:39 pm

Beth,

One way is to search the view definition for the table name...

Example

Code: Select all

dbadmin=> create table snoopy (c1 varchar(1));
CREATE TABLE
dbadmin=> create view woodstock as select * from snoopy;
CREATE VIEW
dbadmin=> select table_schema, table_name, view_definition from views where view_definition ilike '%snoopy%';
 table_schema | table_name |            view_definition
--------------+------------+---------------------------------------
 snowfall     | woodstock  | SELECT snoopy.c1 FROM snowfall.snoopy
(1 row)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “New to Vertica Database Administration”