方式一:(表大时较慢)
select count(*) as rows
from table_name
方式二:(数据库里本身存的信息,速度较快)
SELECT a
.name
, b
.rows,b
.indid
FROM sysobjects
AS a
INNER JOIN sysindexes
AS b
ON a
.id
= b
.id
WHERE b
.indid
in (0,1)
and a
.name
= 'table_name'
ORDER BY a
.name
,b
.rows DESC
如查询表DM_FACT_SALES的数据行数
SELECT a
.name
, b
.rows,b
.indid
FROM sysobjects
AS a
INNER JOIN sysindexes
AS b
ON a
.id
= b
.id
WHERE b
.indid
in (0,1)
and a
.name
= 'DM_FACT_SALES'
ORDER BY a
.name
,b
.rows DESC
转载请注明原文地址:https://ipadbbs.8miu.com/read-53185.html