Answers:
information_schema
这是符合标准的跨RDBMS的方法。
SELECT table_catalog, table_schema, table_name, column_name
FROM INFORMATION_SCHEMA.columns
WHERE column_name = '<your column name>';
您可以看到此文档
INFORMATION_SCHEMA
我们自己的@AaronBertrand(sqlblog.com/blogs/aaron_bertrand/archive/2011/11/03/…)
information_schema.columns
自2006年以来一直支持Identity Columns 。甚至整整十年甚至都没有实现它们。如果Microsoft SQL不支持该标准,也许我们应该考虑一下。别人做。
以下查询应为您提供所需的信息:
use YourDatabase;
go
select
object_schema_name(t.object_id) + '.' + t.name as table_name,
c.name as column_name
from sys.tables t
inner join sys.columns c
on t.object_id = c.object_id
where c.name like '%ColumnSearchText%';
如果要查找确切名称的列,只需将WHERE
子句替换为:
where c.name = 'ColumnSearchText';
在Teradata 15中:
SELECT DATABASENAME||'.'||TABLENAME AS FULL_TABLENAME,
COUNT(1) AS NUMBER_OF_COLUMNS
FROM DBC.COLUMNSV
WHERE 1 = 1
AND COLUMNNAME LIKE '%<YOUR COLUMNNAME HERE>%'
GROUP BY 1