查询与SQL Server数据库有关

时间:2014-02-17 22:24:42

标签: sql-server

在一个数据库中查找多个表的结构和大小的简单方法是什么,例如名称,列数,一个语句中的行数?

3 个答案:

答案 0 :(得分:1)

不确定行,其余的可以通过Information Schema

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

答案 1 :(得分:1)

这个获取行但不显示列数:

sp_MSforeachtable @command1="select count(*) from ?"

(从这里http://www.sqlservercentral.com/Forums/Topic271576-5-1.aspx

答案 2 :(得分:-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)