How to generate Data dictionary in MySql

In this post I am going to explain about how to generate Data dictionary in MySql database. In the earlier posts we learned about installation of MySql, import and export databases , MySql table schema, MySql database backup and MySql views. We can have simple query which will in below code and change database name with yours then you will get data dictionary of your database in MySql.

How to generate Data dictionary in MySql by Anil Kumar Panigrahi

How to generate Data dictionary in MySql by Anil Kumar Panigrahi

MySql Code:

select t.table_schema as db_name,  
t.table_name,  
(case when t.table_type = 'BASE TABLE' then 'table'
when t.table_type = 'VIEW' then 'view' 
else t.table_type  
end) as table_type,
c.column_name, 
c.column_type, 
c.column_default,  
c.column_key,  
c.is_nullable, 
c.extra,   
c.column_comment   
from information_schema.tables as t
inner join information_schema.columns as c 
on t.table_name = c.table_name 
and t.table_schema = c.table_schema
where t.table_type in('base table', 'view')
and t.table_schema = '<database name>' 
order by t.table_schema, t.table_name, c.ordinal_position

Note: < database name > change it with your database name.

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

8 Responses

  1. Chris C says:

    Many thanks!

  2. Janaka says:

    Wow great.. Thanks 🙂

  3. Shalin says:

    If you have a diagram already, you can convert it to data dictionary

  4. Chatura says:

    Great staff bro

  5. Paco says:

    Thanks, it’s work great.

  1. December 7, 2017

    […] How to generate Data dictionary in MySql […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.