In fact, we only use the show usage in the mysql tutorial. The simple operation in mysql is as follows:
Show table
In this way, all the tables are displayed, but they are different in the php tutorial. Let's look at the following code:
$ Server = 'localhost ';
$ User = 'root ';
$ Pass = '';
$ Dbname = 'dayanmei _ com ';
$ Conn = mysql_connect ($ server, $ user, $ pass );
If (! $ Conn) die ("database tutorial system connection failed! ");
Mysql_select_db ($ dbname) or die ("database connection failed! ");
$ Result = mysql_query ("show tables ");
While ($ row = mysql_fetch_array ($ result ))
{
Echo $ row [0]. "";
}
Mysql_free_result ($ result );
Use the mysql_query query function to save the returned table to a data record and traverse it.
Other show operations
Show databases;
Show tables from db_name;
Show columns from table_name from db_name;
Show index from talbe_name [from db_name];
Show status;
Show variables;
Show [full] processlist;
Show table status [from db_name];
Show grants for user;
In addition to status, processlist, and grants, other options can contain the like wild option, which can use the SQL '%' and '_' characters;
Show databases like '% T ';
All databases whose names end with the 'T' character will be listed
Of course, in these SQL statements, you can also use db_name.table_name to replace table_name from db_name for easier writing!
If a user does not have any permissions for a table, the table is not displayed in the output of show tables or mysqlshow db_name.
You may still remember describe table_name, which achieves the same effect as show columns from db_name.table_name.