MYSQL8-快速生成表结构(用于生成文档)
各种工具都有,没有特别趁手的。不如自己用sql处理。
SELECT column_name AS CODE, CASE WHEN column_comment IS NULL OR TRIM(column_comment)='' THEN column_name ELSE CASE WHEN INSTR(column_comment,'-')>0 THEN SUBSTR(column_comment,1,INSTR(column_comment,'-')-1) WHEN INSTR(column_comment,'(')>0 THEN SUBSTR(column_comment,1,INSTR(column_comment,'(')-1) WHEN INSTR(column_comment,'(')>0 THEN SUBSTR(column_comment,1,INSTR(column_comment,'(')-1) WHEN INSTR(column_comment,';')>0 THEN SUBSTR(column_comment,1,INSTR(column_comment,';')-1) WHEN INSTR(column_comment,'|')>0 THEN SUBSTR(column_comment,1,INSTR(column_comment,'|')-1) WHEN INSTR(column_comment,' ')>0 THEN SUBSTR(column_comment,1,INSTR(column_comment,' ')-1) WHEN INSTR(column_comment,',')>0 THEN SUBSTR(column_comment,1,INSTR(column_comment,',')-1) ELSE column_comment END END AS column_name , column_type, column_comment ,is_nullable FROM information_schema.columns WHERE table_name='xxxx' AND table_schema='xxx' ORDER BY ordinal_position
执行效果如下:

本文来自博客园,作者:正在战斗中,转载请注明原文链接:https://www.cnblogs.com/lzfhope/p/16392570.html
浙公网安备 33010602011771号