From surenkid, 1 Month ago, written in MySQL.
Embed
  1. SET @dbname = 'mysql'; -- 指定要生成数据字典的数据库
  2. USE information_schema;
  3.     -- T.TABLE_SCHEMA AS '数据库名称',
  4.     T.TABLE_NAME AS '表名',
  5.     -- T.TABLE_TYPE AS '表类型',
  6.     -- T. ENGINE AS '数据库引擎',
  7.     C.ORDINAL_POSITION AS '字段编号',
  8.     C.COLUMN_NAME AS '字段名',
  9.     C.COLUMN_TYPE AS '数据类型',
  10.     C.IS_NULLABLE AS '允许为空',
  11.     C.COLUMN_KEY AS '键类型',
  12.     C.EXTRA AS '自增属性',
  13.     -- C.CHARACTER_SET_NAME AS '编码名称',
  14.     C.COLUMN_COMMENT AS '字段说明'
  15.     COLUMNS C
  16. INNER JOIN TABLES T ON C.TABLE_SCHEMA = T.TABLE_SCHEMA
  17. AND C.TABLE_NAME = T.TABLE_NAME
  18.     T.TABLE_SCHEMA = @dbname