SQL to report table structure in MySQL
I am using this to automate generation of database design document after reverse engineering using MySQL Workbench
select
table_schema "TABLE SCHEMA",
TABLE_NAME "TABLE NAME",
COLUMN_KEY "COLUMN KEY",
COLUMN_NAME "COLUMN NAME",
ORDINAL_POSITION "COLUMN POSITION",
COLUMN_TYPE "COLUMN TYPE" ,
ifnull(COLUMN_DEFAULT,'') "COLUMN DEFAULT",
IS_NULLABLE "IS NULLABLE" ,
coalesce( CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, DATETIME_PRECISION ) "MAXIMUM LENGTH",
EXTRA "REMARKS",
COLUMN_COMMENT DESCRIPTION
from information_schema.columns
where
table_schema not in
('information_schema','mysql', 'sys','performance_schema')
I am using this to automate generation of database design document after reverse engineering using MySQL Workbench
select
table_schema "TABLE SCHEMA",
TABLE_NAME "TABLE NAME",
COLUMN_KEY "COLUMN KEY",
COLUMN_NAME "COLUMN NAME",
ORDINAL_POSITION "COLUMN POSITION",
COLUMN_TYPE "COLUMN TYPE" ,
ifnull(COLUMN_DEFAULT,'') "COLUMN DEFAULT",
IS_NULLABLE "IS NULLABLE" ,
coalesce( CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, DATETIME_PRECISION ) "MAXIMUM LENGTH",
EXTRA "REMARKS",
COLUMN_COMMENT DESCRIPTION
from information_schema.columns
where
table_schema not in
('information_schema','mysql', 'sys','performance_schema')
No comments:
Post a Comment