常用SQL语句

学海无涯 / 2023-05-13 / 原文

查询数据库中全部表名和行数

SELECT a.NAME
    ,b.rows
FROM sysobjects AS a
INNER JOIN sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u')
    AND (
        b.indid IN (
            0
            ,1
            )
        )
ORDER BY a.NAME
    ,b.rows DESC

查询全部数据库信息

select * from sysdatabases

查询当前数据库中所有表名

select * from sysobjects where xtype='U'