0

What is a simple way to find structure and size of the multiple tables in one database, such as names, number of columns, number of rows in one statement?

  • take a look [here](http://stackoverflow.com/questions/1443704/query-to-list-number-of-records-in-each-table-in-a-database) – abhi Feb 17 '14 at 22:42

3 Answers3

1

Not sure about rows, the rest can be found via the Information Schema

select Table_Name, COUNT(Column_Name) As NumberOfColumns
from INFORMATION_SCHEMA.COLUMNS 
where table_catalog = @DBName
group by Table_Name
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
1

This one gets the rows but won't show the column count:

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

(from here http://www.sqlservercentral.com/Forums/Topic271576-5-1.aspx)

Nick.Mc
  • 18,304
  • 6
  • 61
  • 91
-1

i think you are asking about number of rows in a table look at this

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