List all default values in MariaDB database

The query below lists all default values defined in the database (schema).

Check this query to see them organized by table.

Query

select table_schema as database_name,
       table_name,
       column_name,
       column_default
from information_schema.columns
where  column_default is not null
      and table_schema not in ('information_schema', 'sys',
                               'performance_schema','mysql')
     --    and table_schema = 'your database name'
order by column_name;

Columns

  • database_name - name of the database (schema)
  • table_name - name of the table
  • column_name - name of the column
  • column_default - SQL expression that defines this column default

Rows

  • One row: represents one column with defined default value
  • Scope of rows: all columns with default values in the database (schema)
  • Ordered by: column name

Sample results