$get_sql = "SELECT sql_calc_found_rows field1,field2 FROM table WHERE name = '1' order by add_time desc limit 2,20 "; $get_total_sql = "SELECT FOUND_ROWS() as total";…
SQL Server 获取数据的总记录数,有两种方式: 1.先分页获取数据,然后再查询一遍数据库获取到总数量 2.使用count(1) over()获取总记录数量 SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) rn, ) OVER() AS TotalCount, Id FROM dbo.T_User )a WHERE a.rn 第二种方式既分页还能获取到总记录数量.就是多一个字段,如果获取一次数据较多的话,会浪费一些流量.…
ORACLE根据账号查询每张表数据量: select t.table_name,t.num_rows from user_tables t ORDER BY NUM_ROWS DESC; SQL SERVER查询总数据量: SELECT SUM(记录条数) AS 总记录数 FROM (SELECT TOP (10000) a.name AS 表名, MAX(b.rows) AS 记录条数 FROM sys.sysobjects AS a INNER JOIN sys.sysindexes AS…