查询数据库中所有表名

时间:2022-05-16 05:16:04

查询数据库中所有表名
select table_name from information_schema.tables where table_schema='csdb' and table_type='base table';


查询指定数据库中指定表的所有字段名column_name
select column_name from information_schema.columns where table_schema='csdb' and table_name='users'

 

php获取:

$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);