Search the MySQL manual:
MySQL Manual

Buy this Reference Manual in softcover from Barnes & Noble!

/ Next / Up / Table of Contents

4.5.6 Синтаксис команды SHOW

SHOW DATABASES [LIKE wild]
или SHOW [OPEN] TABLES [FROM db_name] [LIKE wild]
или SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
или SHOW INDEX FROM tbl_name [FROM db_name]
или SHOW TABLE STATUS [FROM db_name] [LIKE wild]
или SHOW STATUS [LIKE wild]
или SHOW VARIABLES [LIKE wild]
или SHOW LOGS
или SHOW [FULL] PROCESSLIST
или SHOW GRANTS FOR user
или SHOW CREATE TABLE table_name
или SHOW MASTER STATUS
или SHOW MASTER LOGS
или SHOW SLAVE STATUS

Команда SHOW предоставляет информацию по базам данных, таблицам, столбцам или о состоянии сервера. Если используется LIKE wild, то строка wild может содержать в себе шаблонные символы SQL `%' и `_'.

Главы

User Comments

Posted by scott hemminger on Tuesday November 5 2002, @1:07pm [Delete] [Edit]

how do you utilize the "SHOW DATABASES"
command in scripting (PHP)? For instance, if you
use a SELECT fieldname FROM tablename, you can
loop through the results and reference the fieldname
variable as row["fieldname"]. How do you reference
the results of the SHOW DATABASES? row
["databases"] does not work. The only usefullness
I've seen from this is with a command line php, I see
no way of utilizing the results of this query in PHP.

Posted by on Wednesday December 18 2002, @5:27pm [Delete] [Edit]

SHOW, EXPLAIN and other related commands
can be
manipulated in PHP just as if they were SELECTs,
e.g.:
$result = mysql_query("SHOW DATABASES");

while($row = mysql_fetch_assoc($result)) {
echo "

Database {$row['Database']}
exists.

\n";
}

Posted by John Hicks on Friday February 28 2003, @10:07am [Delete] [Edit]

You can use the USE statement to define a default database for the SHOW statement (and for all mysql statements). Here's a typical sequence of statements to execute upon logging in in order to orient yourself:

SHOW DATABASES;
USE databaseOfInterest;
SHOW TABLES;
DESCRIBE tableOfInterest;

Posted by Paul Kok on Wednesday March 5 2003, @6:34am [Delete] [Edit]

You also can easily copy tables with this command. Here I have the code for it:
____________________________________________________________

mysql_select_db("db",$link);
$query="show create table stap";
$result=mysql_query($query);
$row = mysql_fetch_array($result);
mysql_select_db("db_1",$link);
$query=$row[1];
mysql_query($query);
____________________________________________________________

Greetings

Add your own comment.

Top / / Next / Up / Table of Contents