List all computed (generated) columns in MySQL database

Query below lists all computed (generated) columns in MySQL database

Query

select table_schema as database_name,
       table_name,
       column_name,
       data_type,
       generation_expression
from information_schema.columns 
where length(generation_expression) > 0
      and table_schema not in ('information_schema', 'sys',
                               'performance_schema', 'mysql')
order by table_schema,
         table_name,
         column_name;

Columns

  • database_name - database (schema) name containing table
  • table_name - table name
  • column_name - name of the column
  • data_type - data type of column
  • generation_expression - computing formula

Rows

  • One row represents one column
  • Scope of rows: represents all computed columns from all databases(schemas)
  • Ordered by database name, table name and column name

Sample results

0
There are no comments. Click here to write the first comment.