January 19th, 2010, 09:20 AM
Check if table is a view
Is there a way for me to query the db to see if a table is a view..?
January 19th, 2010, 11:06 AM
have a look at the INFORMATION_SCHEMA
January 19th, 2010, 11:18 AM
A table can never be a view (because it's a table)
Originally Posted by SpiritedAway
(Sorry, could not resist)
But if you want to know if a name refers to a table or a view then follow r937's advice.
January 20th, 2010, 01:19 AM
Tx for your time chaps - looking into it now...
1st time working with views so good to know the proper way of referring to them
January 20th, 2010, 03:34 AM
To get list of tables and view you can use select from information_schema.tables -
This system table contans all tables and all views; this table has 'TABLE_TYPE' field, you could use it to define type of object -
SELECT * FROM information_schema.tables;
For example -
And there is information_schema.views system table, it contains all views.
SELECT * FROM information_schema.tables WHERE 'TABLE_TYPE' = 'BASE TABLE'; -- Gets all tables
SELECT * FROM information_schema.tables WHERE 'TABLE_TYPE' = 'VIEW'; -- Gets all views, without information_schema system views
Last edited by r937; January 20th, 2010 at 08:19 AM.
October 5th, 2012, 06:16 AM
This may help you
select table_name from information_schema.views;
October 5th, 2012, 06:48 AM
For myself, I always prefix views with 'v_'. I never prefix tables (with, for instance, 'tbl_' or 't_') on the assumption that everything is a table unless otherwise stated.
October 5th, 2012, 07:07 AM
that will not help
Originally Posted by shabarinath
did you even read this (dormant) thread before making that reply?
October 5th, 2012, 07:35 AM
>did you even read this (dormant) thread before making that reply?
Oh, darn it! I fell for it again!
October 5th, 2012, 08:18 AM
Why man he needs all the indexes list naa
Originally Posted by r937