SQL 按名称查找所有数据库对象?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/639895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:24:09  来源:igfitidea点击:

Find all Database Objects by Name?

sqlsql-server

提问by ProfK

How can I find all database objects in a given database using an object name? We prefix all site specific tables, views, indexes, functions, constraints etc. with a constant string. I need to find all objects with names starting with that string.

如何使用对象名称查找给定数据库中的所有数据库对象?我们使用常量字符串作为所有站点特定表、视图、索引、函数、约束等的前缀。我需要找到名称以该字符串开头的所有对象。

回答by JosephStyons

Assuming you have the right permissions:

假设您拥有正确的权限:

SELECT *
FROM yourdatabasename.sys.all_objects
WHERE upper(name) like upper('my prefix%')  --use UPPER for case-INsensitivity