查询以检索具有特定列名的数据库中的所有表 [英] query to retrieve all the tables in the database having a particular column name

查看:98
本文介绍了查询以检索具有特定列名的数据库中的所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为'stars'的数据库,我有很多表。现在我需要在该特定数据库下的所有表中搜索列名Name的出现位置。你能帮我怎样才能做到这一点

I have a database named as 'stars' under which I have many tables. Now I need to search for the occurrence of the column name 'Name' in all the table under that particular database. Can you please help how can I do this

推荐答案

试试

如何在数据库的所有表中搜索列名以及如何搜索包含特定文本的存储过程 [ ^ ]

SQL SERVER - 查询从所有数据库表中查找列 [ ^ ]

T-SQL查找数据库中的列名 [ ^ ]
Try
How to search a column name within all tables of a database and how to search stored procedures containing a particular text[^]
SQL SERVER – Query to Find Column From All Tables of Database[^]
T-SQL Find column name in database[^]


SQL有一组广泛的视图来查看不同类型的系统对象:目录视图 [ ^ ]

使用这些视图,您可以获得有关您所在数据库的大量信息(以及其他也许):

SQL has a wide set of views to see different kinds of system objects: Catalog Views[^]
Using these views you can get a lot of information about the database you are in (and others maybe):
SELECT SYS.COLUMNS.NAME, SYS.TABLES.NAME
FROM SYS.COLUMNS
    INNER JOIN SYS.TABLES ON SYS.TABLES.OBJECT_ID = SYS.COLUMNS.OBJECT_ID
WHERE SYS.COLUMNS.NAME = 'column-name-you-are-looking-for'


以下查询将帮助您查找具有名称列的表名



The below query will help you to find out table name which are having "Name" column

select table_name 'Table Name' from information_schema.columns
where column_name = 'Name'


这篇关于查询以检索具有特定列名的数据库中的所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆