枚举 sql server 中的表名 (zz)

本文提供了在不同版本的SQL Server中查询所有用户表的方法,包括SQL Server 2000及更高版本。文中详细展示了如何使用SQL语句获取表名及相关信息,并列举了多种对象类型供进一步搜索。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//z 2012-3-16 11:34:36 AM IS2120@优快云

SQL Server 2005 or 2008:

SELECT * FROM information_schema.tables

SQL Server 2000:

SELECT * FROM sysobjects WHERE xtype='U'


SELECT sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U'

Here is a list of other object types you can search for as well:

  • C: Check constraint
  • D: Default constraint
  • F: Foreign Key constraint
  • L: Log
  • P: Stored procedure
  • PK: Primary Key constraint
  • RF: Replication Filter storedprocedure
  • S: System table
  • TR: Trigger
  • U: User table
  • UQ: Unique constraint
  • V: View
  • X: Extended stored procedure
//z 2012-3-16 11:34:36 AM IS2120@优快云

SELECT * FROM INFORMATION_SCHEMA.TABLES 

or Sys.Tables



exec sp_msforeachtable 'print ''?'''
//z 2012-3-16 11:34:36 AM IS2120@优快云

转载于:https://www.cnblogs.com/IS2120/archive/2012/03/16/6745924.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值