MySQL 5 und Views

Hier ein paar SQL-Aufrufe, die man für Views unter MySQL 5 braucht (von http://dev.mysql.com/doc/refman/5.0/en/views-table.html).

# 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 = ?;

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>