Specifications

11
ADVANCED
MY
SQL
Advanced MySQL
C
HAPTER 11
255
+------------------------------------------------------------------------------------------------+
| Grants for bookorama@% |
+------------------------------------------------------------------------------------------------+
|GRANT USAGE ON *.* TO 'bookorama'@'%' IDENTIFIED BY PASSWORD '6a87b6810cb073de' |
|GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON books.* TO 'bookorama'@'%' |
+------------------------------------------------------------------------------------------------+
If you leave the database parameter off, the SHOW COLUMNS statement will default to the data-
base currently in use. You can also use the table.column notation:
show columns from books.orders;
One other very useful variation of the SHOW statement can be used to see what privileges a user
has. For example, if we run the following, well get the output shown in Figure 11.1:
show grants for bookorama;
FIGURE 11.1
The output of the SHOW GRANTS statement.
The GRANT statements shown are not necessarily the ones that were executed to give privileges
to a particular user, but rather summary equivalent statements that would produce the users
current level of privilege.
The SHOW GRANTS statement was added in MySQL version 3.23.4if you have an ear-
lier version, this statement wont work.
NOTE
There are many other variations of the SHOW statement. A summary of all the variations is
shown in Table 11.6.
T
ABLE 11.6 SHOW Statement Syntax
Variation Description
SHOW DATABASES Lists available databases, optionally
[LIKE database] with names like database.
SHOW TABLES [FROM database] Lists tables from the database
[LIKE table] currently in use, or from the database called
database if specified, optionally with table
names like table.
14 7842 CH11 3/6/01 3:35 PM Page 255