Mysql – Does MySQL have information_schema.VIEW_COLUMN_USAGE or an equivalent

information-schemaMySQLview

SQL Server has a an information_schema view, 'VIEW_COLUMN_USAGE', which you can use to determine the actual/base tables that the columns in a view reside in.

I'm looking for the equivalent in MySQL – the only view-related information_schema item i can see is VIEWS which has no column info.

Is the only way to find the tables that the columns in a view belongs to to parse the view definition? This seems rather barbaric, and maybe not possible if one doesn't control the SQL being used to define views.

Thanks for your time!

Best Answer

Sorry - the answer is: no. Indeed what you found is the only thing in I_S regarding views.

Not only is this barbaric on the client side, it is also such on the server side: when you:

SELECT ... FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='your_view'

MySQL actually drills down to referenced table definitions and this type of query is very costly if there are many nested views (I have a particular case on my servers).