The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> MySQL Help
|
Check if table is a view
Discuss Check if table is a view in the MySQL Help forum on Dev Shed. Check if table is a view MySQL Help forum discussing administration, SQL syntax, and other MySQL-related topics. MySQL is an open-source relational database management system (RDBMS).
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 19th, 2010, 08:20 AM
|
|
Contributing User
|
|
Join Date: Dec 2008
Posts: 55
Time spent in forums: 20 h 33 m 24 sec
Reputation Power: 5
|
|
|
Check if table is a view
Hi people,
Is there a way for me to query the db to see if a table is a view..?
Thanks
|

January 19th, 2010, 10:06 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
have a look at the INFORMATION_SCHEMA 
|

January 19th, 2010, 10:18 AM
|
|
Contributing User
|
|
Join Date: Oct 2003
Location: Germany
|
|
Quote: | Originally Posted by SpiritedAway Is there a way for me to query the db to see if a table is a view..? | A table can never be a view (because it's a table)
(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, 12:19 AM
|
|
Contributing User
|
|
Join Date: Dec 2008
Posts: 55
Time spent in forums: 20 h 33 m 24 sec
Reputation Power: 5
|
|
Tx for your time chaps - looking into it now...
@shammat
1st time working with views so good to know the proper way of referring to them 
|

January 20th, 2010, 02:34 AM
|
 |
Contributing User
|
|
|
|
To get list of tables and view you can use select from information_schema.tables -
Code:
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 -
For example -
Code:
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
And there is information_schema.views system table, it contains all views.
Last edited by r937 : January 20th, 2010 at 07:19 AM.
|

October 5th, 2012, 05:16 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 2
Time spent in forums: 14 m 48 sec
Reputation Power: 0
|
|
|
This may help you
select table_name from information_schema.views;
|

October 5th, 2012, 05: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, 06:07 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
Quote: | Originally Posted by shabarinath select table_name from information_schema.views; | that will not help
did you even read this (dormant) thread before making that reply?
|

October 5th, 2012, 06:35 AM
|
|
|
|
>did you even read this (dormant) thread before making that reply?
Oh, darn it! I fell for it again!
|

October 5th, 2012, 07:18 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 2
Time spent in forums: 14 m 48 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by r937 that will not help
did you even read this (dormant) thread before making that reply? |
Why man he needs all the indexes list naa
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|