所以现在这是我的代码:
$mysqli = new mysqli("localhost", "username", "password", "dbname"); // connect
if (mysqli_connect_errno()) { // checking connection
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
因此,此数据库中有几个表。我想显示所有表的所有名称。我已经在互联网上搜索了一段时间,但我无法找到正确的答案。提前谢谢!
答案 0 :(得分:2)
您想要的SQL语句是:
SHOW TABLES;
答案 1 :(得分:1)
您可以在PHP代码中使用这些查询:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| begueradj |
| mysql |
| performance_schema |
| phpmyadmin |
| tester |
+--------------------+
6 rows in set (0.04 sec)
mysql> use tester;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+------------------+
| Tables_in_tester |
+------------------+
| images |
+------------------+
1 row in set (0.00 sec)