在mysql要顯示指定數(shù)據(jù)庫(kù)中所有表名我們有一個(gè)命令SHOW TABLES就可以實(shí)現(xiàn)了,下面我來(lái)看看關(guān)于SHOW TABLES是如何獲取mysql數(shù)據(jù)庫(kù)中所有表名的.
直接cmd命令模式下使用,代碼如下:
- 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;
結(jié)合php mysql數(shù)據(jù)庫(kù)使用,代碼如下:
- $server = 'localhost';
- $user = 'root';
- $pass = '';
- $dbname = 'dayanmei_com';
- $conn = mysql_connect($server,$user,$pass);
- if(!$conn) die("數(shù)據(jù)庫(kù)系統(tǒng)連接失敗!");
- mysql_select_db($dbname) or die("數(shù)據(jù)庫(kù)連接失敗!");
- $result = mysql_query("SHOW TABLES");
- while($row = mysql_fetch_array($result))
- { //開(kāi)源代碼Vevb.com
- echo $row[0]."";
- mysql_free_result($result);
- }
注意:php中列表mysql中所有表名的函數(shù)mysql_list_tables,已經(jīng)刪除了,建議不要使用該函數(shù)列表mysql數(shù)據(jù)表.
新聞熱點(diǎn)
疑難解答