OPTIMIZE TABLE
ANALYZE TABLE
FLUSH
RESET
KILL
SHOW
SHOW TABLE STATUS
SHOW STATUS
SHOW VARIABLES
SHOW LOGS
SHOW PROCESSLIST
SHOW GRANTS
SHOW CREATE TABLE
SHOW WARNINGS | ERRORS
SHOW TABLE TYPES
SHOW PRIVILEGES
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 WARNINGS [LIMIT #] или SHOW ERRORS [LIMIT #] или SHOW TABLE TYPES
Команда SHOW
предоставляет информацию по базам данных, таблицам, столбцам
или о состоянии сервера. Если используется LIKE wild
, то строка wild
может
содержать в себе шаблонные символы SQL `%' и `_'.
SHOW TABLE STATUS
SHOW STATUS
SHOW VARIABLES
SHOW LOGS
SHOW PROCESSLIST
SHOW GRANTS
SHOW CREATE TABLE
SHOW WARNINGS | ERRORS
SHOW TABLE TYPES
SHOW PRIVILEGES
User Comments
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.
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 "<p>Database {$row['Database']}
exists.</p>\n";
}
You can use the USE <databasename> 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;
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
To show tables with PHP and MySQL:
mysql_select_db("foobar");
$query = "show tables";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
print "There are $num_results tables.<br>";
for ($i = 0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
print "table " . $row[0] . " exists.<br>";
}
$row[0] will hold the table name.
you can use this command too...
<?
$db=mysql_connect($host,$user,$passwd);
$tbl=mysql_query("SHOW DATABASES");
for ($i=0;$i<mysql_num_rows($tbl);$i++){
$database=mysql_result($tbl,$i,0);
}
.
.
.
?>
Add your own comment.