Prev | Current Page 232 | Next

Marc Delisle

"Mastering phpMyAdmin 2.11 for Effective MySQL Management"


To activate views support on a server after an upgrade from a pre-5.0 version,
the administrator has to execute the mysql_fix_privileges_tables script, as
described in the MySQL manual.
Each user must have the appropriate SHOW_VIEW or CREATE_VIEW
privilege to be able to see or manipulate views. These privileges exist at
the global (server), database and table levels.
phpMyAdmin supports two ways of creating a view; we'll explain first the manual
method, then go on with a more automatic way.
Manually Creating a View
To manually create a view, we use the query box to enter the appropriate statement.
Let's input the following lines and click Go:
CREATE VIEW book_author AS
SELECT book.isbn, book.title, author.name FROM book
LEFT JOIN author ON author.id = book.author_id
Creating a view implies that the user has privileges on the tables
involved, or at least a privilege like SELECT or UPDATE on all the columns
mentioned in the view.
??? ??? ???
Chapter 18
[ 267 ]
At this point, the view has been created and the left panel is updated to reflect this fact.
If we refresh our browser's page, and then access the marc_book database, we see:
In the left panel, there is a different icon next to the book_author view; it can be used
to browse this view. In the right panel, we see the newly created view's information.
The number of records for the view currently indicates 0 (more on this in the
Performance Hint section, later in this chapter), and View is indicated in the Type
column.


Pages:
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244