The VIEWS table provides information about
views in databases. You must have the SHOW VIEW
privilege to access this table.
INFORMATION_SCHEMA
Name |
SHOW Name |
Remarks |
TABLE_CATALOG |
NULL |
|
TABLE_SCHEMA |
||
TABLE_NAME |
||
VIEW_DEFINITION |
||
CHECK_OPTION |
||
IS_UPDATABLE |
||
DEFINER |
||
SECURITY_TYPE |
||
CHARACTER_SET_CLIENT |
MySQL extension | |
COLLATION_CONNECTION |
MySQL extension |
Notes:
The VIEW_DEFINITION column has most of what
you see in the Create Table field that
SHOW CREATE VIEW produces. Skip the words
before SELECT and skip the words
WITH CHECK OPTION. Suppose that the
original statement was:
CREATE VIEW v AS SELECT s2,s1 FROM t WHERE s1 > 5 ORDER BY s1 WITH CHECK OPTION;
Then the view definition looks like this:
SELECT s2,s1 FROM t WHERE s1 > 5 ORDER BY s1
The CHECK_OPTION column always has a value
of NONE.
MySQL sets a flag, called the view updatability flag, at
CREATE VIEW time. The flag is set to
YES (true) if UPDATE and
DELETE (and similar operations) are legal
for the view. Otherwise, the flag is set to
NO (false). The
IS_UPDATABLE column in the
VIEWS table displays the status of this
flag. It means that the server always knows whether a view is
updatable. If the view is not updatable, statements such
UPDATE, DELETE, and
INSERT are illegal and will be rejected.
(Note that even if a view is updatable, it might not be
possible to insert into it; for details, refer to
Section 25.2, “CREATE VIEW Syntax”.)
The DEFINER column indicates who defined
the view. SECURITY_TYPE has a value of
DEFINER or INVOKER.
CHARACTER_SET_CLIENT is the session value
of the character_set_client system variable
when the view was created.
COLLATION_CONNECTION is the session value
of the collation_connection system variable
when the view was created. These columns were added in MySQL
5.1.21.

User Comments
Theese queries may come in handy:
# list all views
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.VIEWS;
# describe view
# replace ? with view name
SELECT VIEW_DEFINITION
FROM INFORMATION_SCHEMA.VIEWS
WHERE
TABLE_NAME = ?;
# describe view prettyprinted
# replace ? with view name
SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(VIEW_DEFINITION, ",", "\n"),
"from", "\nfrom"), "where", "\nwhere"), "join", "\njoin"), "and", "\nand")
FROM INFORMATION_SCHEMA.VIEWS
WHERE
TABLE_NAME = ?;
Add your own comment.