怎样取得某个服务器中数据库的个数,库中的表数?

eminena 2003-08-22 10:05:37
公司的数据库服务器是共用的,你建库,他建库,请问:

1.怎样取得该服务器上的数据库数及数据库名称等信息?

2.怎样取得某个数据库中表的个数?
...全文
35 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2003-08-22
  • 打赏
  • 举报
回复
1.怎样取得该服务器上的数据库数及数据库名称等信息?
exec sp_databases
select * from sysdatabases

2.怎样取得某个数据库中表的个数?
select name from sysobjects where xtype='u'
sp_tables
select * from INFORMATION_SCHEMA.TABLES
select * from sysobjects where xtype='U' and status>0

都可以,你要求个数:
select count(*) from sysobjects where xtype='U' and status>0
pengdali 2003-08-22
  • 打赏
  • 举报
回复
1.怎样取得该服务器上的数据库数及数据库名称等信息?
exec sp_databases
select * from sysdatabases

2.怎样取得某个数据库中表的个数?
select name from sysobjects where xtype='u'
sp_tables
select * from INFORMATION_SCHEMA.TABLES
select * from sysobjects where xtype='U' and status>0

都可以,你要求个数:
select count(*) from sysobjects where xtype='U' and status>0
txlicenhe 2003-08-22
  • 打赏
  • 举报
回复
1:
Select * from master..sysdatabases
2:
Select * from 库名..sysobjects where xtype = 'U'
CrazyFor 2003-08-22
  • 打赏
  • 举报
回复
1.怎样取得该服务器上的数据库数及数据库名称等信息?

select * from master..databases

2.怎样取得某个数据库中表的个数?
select * from 库名..sysobjects where xtype='U'

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧