Search For A Specific Column in Views – MySQL

INFORMATION SCHEMA (also referred as system catalog) gives you access to database metadata and MySQL server information like the name of a database or table, the data type of a column, and access privileges.

We’ll look at how to search a specific column if it’s utilized in VIews in this article.

— Searching a column in all views of a specific database.
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.VIEWS

WHERE TABLE_SCHEMA = ‘TestDB’ AND
VIEW_DEFINITION LIKE ‘%DepartmentID%’;

— Searching a column in all views of all databases.
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.VIEWS

WHERE VIEW_DEFINITION LIKE ‘%DepartmentID%’;

Happy learning!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s