如何将 MySQL 架构转换为 GitHub Wiki Markdown
挑战:
导出 MySQL数据库模式转换为 Markdown 格式以用于文档
解决方案:
利用两个存储过程来完成此任务:
第一个存储过程(describeTables_v2a):
此过程从指定数据库中提取模式信息,准备并将其存储在基于会话的表中。
第二个存储过程 (Print_Tables_Like_Describe):
此过程为指定的所有表生成类似于 MySQL 的 DESCRIBE 语句的输出
用法:
示例:
SET @theOutVar =-1; -- A variable used as the OUT variable below -- Call describeTables_v2a with auto-calling enabled call Reporting101a.describeTables_v2a('stackoverflow', @theOutVar, false, true);
输出:
输出将类似于以下内容:
+--------------------------------------------------------------------------------------------+ | | +--------------------------------------------------------------------------------------------+ | course | | +------------+--------------+------+-----+---------+-------------------+ | | Field | Type | Null | Key | Default | Extra | | +------------+--------------+------+-----+---------+-------------------+ | | courseId | int(11) | NO | PRI | | auto_increment | | +------------+--------------+------+-----+---------+-------------------+ | | deptId | int(11) | NO | MUL | | | | +------------+--------------+------+-----+---------+-------------------+ | | courseName | varchar(100) | NO | | | | | +------------+--------------+------+-----+---------+-------------------+ | | | dept | | +----------+--------------+------+-----+---------+-------------------+ | | Field | Type | Null | Key | Default | Extra | | +----------+--------------+------+-----+---------+-------------------+ | | deptId | int(11) | NO | PRI | | auto_increment | | +----------+--------------+------+-----+---------+-------------------+ | | deptName | varchar(100) | NO | | | | | +----------+--------------+------+-----+---------+-------------------+ | | | scjunction | | +------------+---------+------+-----+---------+-------------------+ | | Field | Type | Null | Key | Default | Extra | | +------------+---------+------+-----+---------+-------------------+ | | id | int(11) | NO | PRI | | auto_increment | | +------------+---------+------+-----+---------+-------------------+ | | studentId | int(11) | NO | MUL | | | | +------------+---------+------+-----+---------+-------------------+ | | courseId | int(11) | NO | MUL | | | | +------------+---------+------+-----+---------+-------------------+ | | term | int(11) | NO | | | | | +------------+---------+------+-----+---------+-------------------+ | | attendance | int(11) | NO | | | |
以上是如何使用存储过程将 MySQL 架构转换为 GitHub Wiki Markdown?的详细内容。更多信息请关注PHP中文网其他相关文章!