PHP Find all table names in MySQL database _php tutorial

Source: Internet
Author: User
Tags php mysql
In MySQL to display all the table names in the specified database we have a command show tables can be implemented, let me take a look at how show tables get all the table names in the MySQL database.

Use Direct cmd command mode

The code is as follows Copy Code


show databases;
Show tables from db_name;

Show columns from table_name to 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;


Combined 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 the PHP list of all table names in MySQL function mysql_list_tables, has been deleted, it is recommended not to use the function list MySQL data table

http://www.bkjia.com/PHPjc/630721.html www.bkjia.com true http://www.bkjia.com/PHPjc/630721.html techarticle in MySQL to display all the table names in the specified database we have a command show tables can be implemented, let me take a look at how show tables get all the table names in the MySQL database. ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.