2014-02-17 36 views
0

什麼是在一個數據庫中查找多個表的結構和大小的簡單方法,例如名稱,列數,一條語句中的行數?與SQL Server數據庫相關的查詢

+0

看一看[這裏](http://stackoverflow.com/questions/1443704/query-to-list-number-of-records-in-each-table-in-a-database) – abhi

回答

-1

我想你問的行數表中的 看看這個

$dbhost = 'localhost';  
$dbname = 'modify this';  
$dbuser = 'and this'; 
$dbpass = 'and this'; 


$link = mysql_connect($dbhost, $dbuser, $dbpass) or die('can not connect to sql'); 
mysql_select_db($dbname) or die('can not select db'); 

$res=mysql_query("SELECT * FROM table"); 
$rows=mysql_num_rows($res); 
echo $rows;//outputs a number (the number of rows in a table) 
+0

標籤說Sql Server。 – abhi

+0

或者你可能需要** JOIN **這樣的表'SELECT * FROM table NATURAL JOIN other table;' – user3299137

1

不確定行,其餘的可以通過Information Schema

select Table_Name, COUNT(Column_Name) As NumberOfColumns 
from INFORMATION_SCHEMA.COLUMNS 
where table_catalog = @DBName 
group by Table_Name