sqlserver 查詢所有表及記錄行數

2022-05-09 05:45:10 字數 1372 閱讀 4001

--

查詢所有表名

select name from sysobjects where xtype='u

'select

*from

sys.tables

--查詢所有表名及對應架構

select t.[

name

]as tablename, s.[

name]as

[schema

]from sys.tables as t,sys.schemas as s where t.schema_id =

s.schema_id

--查詢資料庫中所有的表名及行數

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 b.rows desc

--查詢所有的標明及空間佔用量\行數

select

object_name

(id) tablename,

8*reserved/

1024

reserved,

rtrim(8

*dpages)+'kb

'used,

8*(reserved-dpages)/

1024

unused,

8*dpages/

1024

-rows/

1024

*minlen/

1024

free,

rows

--,*

from

sysindexes

where indid=

1order

by tablename,reserved desc

--

查詢資料庫中所有表名及行數 --帶架構名

select

s.name,a.name, b.rows

from sys.tables as

a inner

join sysindexes as b on a.object_id

=b.id

left

join sys.schemas as s on a.schema_id =

s.schema_id

where (a.type ='u

') and (b.indid in (0, 1

))order

by b.rows desc

SQLserver查詢所有表和表下面所有列

select case when a.colorder 1 then d.name else null end 表名,a.colorder 字段序號,a.name 欄位名,case when columnproperty a.id,a.name,isidentity 1 then else end ...

oracle 查詢表空間所有表 及表所有的表空間

查詢表空間所有表 select table name from all tables where tablespace name 表空間 表空間名字一定要大寫。查詢表所在的表空間 select from user tables where table name 表名 表名一定要大寫 建立表空間 cr...

所有的表sqlserver

select o.name as tablename,user name o.uid as owner,isnull ptb.value,n as tabledescription,c.colid as fieldid,c.name as fieldname,quotename t.name cas...