Home > Backend Development > PHP Tutorial > PHP finds all table names in mysql database_PHP tutorial

PHP finds all table names in mysql database_PHP tutorial

WBOY
Release: 2016-07-13 17:06:12
Original
1176 people have browsed it

To display all table names in a specified database in mysql, we have a command SHOW TABLES to achieve it. Let me take a look at how SHOW TABLES obtains all table names in the mysql database.

Use directly in cmd command mode

The code is as follows
 代码如下 复制代码


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;

Copy code


 代码如下 复制代码

$server = 'localhost';  
$user = 'root';  
$pass = '';  
$dbname = 'dayanmei_com';  
$conn = mysql_connect($server,$user,$pass);  
if(!$conn) die("数据库系统连接失败!");  
mysql_select_db($dbname) or die("数据库连接失败!");  
$result = mysql_query("SHOW TABLES");  
while($row = mysql_fetch_array($result))  
{  
echo $row[0]."";  
mysql_free_result($result);  

}

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 [full] processlist; show table status [from db_name]; show grants for user; Used in combination with php mysql database
The code is as follows Copy code
$server = 'localhost'; $user = 'root'; $pass = ''; $dbname = 'dayanmei_com'; $conn = mysql_connect($server,$user,$pass); if(!$conn) die("Database 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); } Note that the function mysql_list_tables for all table names in the PHP list mysql has been deleted. It is recommended not to use this function list mysql data table http://www.bkjia.com/PHPjc/630721.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630721.htmlTechArticleIn mysql, if you want to display all the table names in the specified database, we have a command SHOW TABLES to achieve it. Let me do it below Take a look at how SHOW TABLES obtains all table names in the mysql database. ...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template