SQLServer元数据查询

SQLServer元数据查询

2023年7月19日发(作者:)

SQLServer元数据查询1、查询触发器的信息--查询触发器的信息 select name, --触发器名称 (select name from s where object_id = _id)as tb_name --表的名称 from

rs t --查询触发器的代码 select * from _modules where object_id = object_id('触发器的名称')2、⼤综合--⽬录视图,或者是系统视图 select * from s select * from select * from ures select * from rs --表 select *

from --列 select * from s --列的类型 select * from --主键约束 select * from _constraints --外键约束 select *

from n_keys select* from n_key_columns --default约束 select* from t_constraints --check约束 select * from

_constraints --identity列 select* from ty_columns --计算列 select * from ed_columns --索引 select * from s

--索引列 select * from _columns --索引的使⽤统计 select * from _db_index_usage_stats --索引的操作统计 select * from

_db_index_operational_stats( DB_ID('数据库名'), OBJECT_ID(''), null, null, null) --索引的物理统计 select * from

_db_index_physical_stats( DB_ID('数据库名'), OBJECT_ID(''), null, null) --动态执⾏的信息 select * from _exec_sessions

select* from _exec_connections select* from _exec_requests select * from _exec_query_stats select * from

_exec_sql_text('sql_handle') select* from _exec_query_plan('query_plan') select * from _exec_plan_attributes('query_plan') --sql缓存计划 select * from _exec_cached_plans --通过指定计划句柄或 SQL 句柄从计划缓存中删除特定计划 dbcc freeproccache --刷新针对

Microsoft SQL Server 实例执⾏的分布式查询所使⽤的分布式查询连接缓存 dbcc freesessioncache --可以使⽤此命令从所有缓存中或者从指定的资源调控器池缓存中⼿动删除未使⽤的条⽬ dbcc freesystemcache('all') --database缓存 select * from _os_buffer_descriptors --清空database缓存 dbcc

dropcleanbuffers --内存分配 select * from _os_memory_clerks --事务 select * from _tran_session_transactions --会话的事务 select *

from _tran_active_transactions --数据库事务 select * from _tran_database_transactions --锁 select * from _tran_locks select *

from _tran_current_transaction --等待 select * from _os_wait_stats --正在等待的task select * from _os_waiting_tasks --tempdb的空间使⽤情况 select * from _db_file_space_usage select * from _db_session_space_usage select * from

_db_task_space_usage --存储 select * from ses select * from se_files select * from _files select * from

_io_virtual_file_stats( DB_ID(), 1 ); select * from _io_pending_io_requests -- select work_queue_count,

pending_disk_io_count, failed_to_create_worker, * from _os_schedulers --备份 backup database master to disk = 'c:' with

format --还原 --若要还原 master 数据库,服务器必须以单⽤户模式运⾏。 --有关在单⽤户模式下启动的信息,请参阅联机丛书中的"如何启动 SQL Server

实例()"。 restore database master from disk = 'c:' with replace --替换现有数据库 --详细的io开销 set statistics io on --详细的cpu开销 set statistics time on --实际的⽂本格式的,执⾏计划 set statistics profile on --DBCC数据库命令控制台 dbcc checkdb('master') --远程数据查询 --从sql server中查询 SELECT * FROM OPENROWSET('SQLOLEDB', 'server=192.168.1.16,1433;uid=sa;pwd=winchannel', --字符串

_store) --直接写表的名称 --从Excel中查询,通过引⽤4.0的库 select * from openrowset('.4.0',

'Excel 5.0;database=c:', sheet1$) --excel,12.0的库 select * from opendatasource('.12.0',

'data source=c:;Extended Properties=Excel 12.0')...[sheet1$]

发布者:admin,转转请注明出处:http://www.yc00.com/news/1689763904a284266.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信