Databases Reference
In-Depth Information
We notice that in the generated SQL query, we do not see our original CREATE VIEW
statement. The reason is that we are selecting from the view, and this is done with
a SELECT statement, hiding the fact that we are pulling data from a view. However,
exporting the view's structure would display how MySQL internally stored our view:
CREATE ALGORITHM=UNDEFINED DEFINER='marc'@'%' SQL SECURITY DEFINER
VIEW `book_author` AS
select `book`.`isbn` AS 'isbn',
`book`.`title` AS 'title',
`author`.`name` AS 'name'
from (`book` left join `author` on((`book`.`author_id` = `author`.
`id`)));
The right panel's menu may look similar to the one for a table, but when needed,
phpMyAdmin generates the appropriate syntax for handling views. For example, a
click on Drop would produce:
Do you really want to: DROP VIEW 'book_author'
At this point, we can confirm (or not) this view's deletion.
To perform actions on views, a user needs to have the appropriate
privilege at the view level, but not necessarily any privilege on the
tables involved in this view. This is how we can achieve column and
table hiding.
Creating a View from Results
Creating a complex view might require typing the complete statement into a query
box. Another possibility is to take advantage of phpMyAdmin's Search (at the table
level) or Query (at the database level) features to build a rather complex query,
execute it, and then easily create a view from the results. We'll see how it is done.
We mentioned that a view can be used to limit the visibility of columns (and in fact, of
tables). Let's say that the number of pages in a book is highly classified information.
We open the topic table, click Search , and choose a subset of the columns:
 
Search WWH ::




Custom Search