find tables with column name in sql code example
Example 1: find table from column name in sql
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName'
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%MyName%'
ORDER BY TableName
,ColumnName;
Example 2: find tables with column name in sql
SELECT * FROM USER_TAB_COLUMNS WHERE COLUMN_NAME = 'MY_COLUMN'; -- Connected user
SELECT * FROM ALL_TAB_COLUMNS WHERE COLUMN_NAME = 'MY_COLUMN'; -- Other schemas
SELECT * FROM DBA_TAB_COLUMNS WHERE COLUMN_NAME = 'MY_COLUMN'; -- All tables