Given a column name, how can I find which tables in the database contain this column?

  • Given the column name, how can I find which tables in the database contain this column?

    or alternatively

  • How can I find this particular column exists for all tables in the database?

Note: Please explain the answers with examples, as I get most of the knowledge from the answer.

Edit: I am using a MySQL database.

+3
source share
3 answers
SELECT * FROM information_schema.columns WHERE COLUMN_NAME = 'mycolumn'
+5
source

. , . , SYSTEMABLE SYSCOLUMN Sybase ASA.

0

in SQL Server:

select distinct t.name
from sys.Columns c 
    inner join sys.tables t on c.object_id = t.object_id
where c.name = 'YOUR_COLUMNNAME'
0
source

Source: https://habr.com/ru/post/1727618/


All Articles