[英]Search for field in database
What's the quickest way to find what table a field is in? 查找字段所在表的最快捷方式是什么? I just started at a new company and I'm not yet familiar with their DB's schema.
我刚开始在一家新公司工作,我还不熟悉他们的DB模式。 I frequently have a metric or dimension that I need to search for and it seems very time consuming as they have a very large DB.
我经常需要搜索的度量标准或维度,因为它们具有非常大的数据库,所以它看起来非常耗时。
I know this is a vague question and there is no best answer, but I'm looking for best practices, tips, and tricks that people have learned over the years which I might be able to leverage in this case. 我知道这是一个模糊的问题,并没有最好的答案,但我正在寻找人们多年来学到的最佳实践,技巧和窍门,在这种情况下我可以利用这些技巧。
You can use sys.columns
for that: 您可以使用
sys.columns
:
SELECT
OBJECT_NAME(c.object_id)
FROM sys.columns c
WHERE c.name = <column_name>
I normally use the following query when I'm searching for a field. 我正在搜索字段时通常使用以下查询。
SELECT * FROM information_schema.COLUMNS c WHERE c.COLUMN_NAME LIKE 'search_field%'
Make sure you have the DB you're interested in selected. 确保您选择了您感兴趣的数据库。
Then, once you find the table you're looking for you can create a DB diagram and 'show related fields' to see how to join that table on what you already have. 然后,一旦找到您正在寻找的表,您就可以创建一个数据库图表并“显示相关字段”,以了解如何将该表连接到您已有的表上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.