:: DEVELOPER ZONE
SHOW CHARACTER SET SyntaxSHOW COLLATION SyntaxSHOW COLUMNS SyntaxSHOW CREATE DATABASE SyntaxSHOW CREATE PROCEDURE and SHOW CREATE FUNCTION SyntaxSHOW CREATE TABLE SyntaxSHOW CREATE VIEW SyntaxSHOW DATABASES SyntaxSHOW ENGINE SyntaxSHOW ENGINES SyntaxSHOW ERRORS SyntaxSHOW GRANTS SyntaxSHOW INDEX SyntaxSHOW INNODB STATUS SyntaxSHOW LOGS SyntaxSHOW OPEN TABLES SyntaxSHOW PRIVILEGES SyntaxSHOW PROCEDURE STATUS and SHOW FUNCTION STATUS SyntaxSHOW PROCESSLIST SyntaxSHOW STATUS SyntaxSHOW TABLE STATUS SyntaxSHOW TABLES SyntaxSHOW TRIGGERS SyntaxSHOW VARIABLES SyntaxSHOW WARNINGS Syntax
SHOW has many forms that provide information
about databases, tables, columns, or status information about
the server. This section describes those following:
SHOW [FULL] COLUMNS FROMtbl_name[FROMdb_name] [LIKE 'pattern'] SHOW CREATE DATABASEdb_nameSHOW CREATE FUNCTIONfuncnameSHOW CREATE PROCEDUREprocnameSHOW CREATE TABLEtbl_nameSHOW DATABASES [LIKE 'pattern'] SHOW ENGINEengine_name{LOGS | STATUS } SHOW [STORAGE] ENGINES SHOW ERRORS [LIMIT [offset,]row_count] SHOW FUNCTION STATUS [LIKE 'pattern'] SHOW GRANTS FORuserSHOW INDEX FROMtbl_name[FROMdb_name] SHOW INNODB STATUS SHOW PROCEDURE STATUS [LIKE 'pattern'] SHOW [BDB] LOGS SHOW PRIVILEGES SHOW [FULL] PROCESSLIST SHOW [GLOBAL | SESSION] STATUS [LIKE 'pattern'] SHOW TABLE STATUS [FROMdb_name] [LIKE 'pattern'] SHOW [OPEN] TABLES [FROMdb_name] [LIKE 'pattern'] SHOW TRIGGERS SHOW [GLOBAL | SESSION] VARIABLES [LIKE 'pattern'] SHOW WARNINGS [LIMIT [offset,]row_count]
The SHOW statement also has forms that
provide information about replication master and slave servers
and are described in Section 13.6, “Replication Statements”:
SHOW BINLOG EVENTS SHOW MASTER LOGS SHOW MASTER STATUS SHOW SLAVE HOSTS SHOW SLAVE STATUS
If the syntax for a given SHOW statement
includes a LIKE
' part,
pattern'' is a
string that can contain the SQL
‘pattern'%’ and
‘_’ wildcard characters. The
pattern is useful for restricting statement output to matching
values.
Several SHOW statements also accept a
WHERE clause that provides more flexibility
in specifying which rows to display. See
Section 20.18, “Extensions to SHOW Statements”.
User Comments
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.