## 简单查询表结构 SQL: ``` desc [table] ``` 示例: ``` MySQL [database]> desc zc_action_log; +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | module | varchar(20) | NO | MUL | NULL | | | target_id | int(11) | NO | MUL | 0 | | | update_time | int(11) | NO | | NULL | | +----------------+--------------+------+-----+---------+----------------+ ``` ## 查询表创建语句 SQL: ``` SHOW CREATE TABLE [table] ``` 示例: ``` MySQL [database]> show create table zc_company_description\G; *************************** 1. row *************************** Table: zc_company_description Create Table: CREATE TABLE `zc_company_description` ( `id` int(11) NOT NULL AUTO_INCREMENT, `content` text NOT NULL COMMENT '内容', `create_time` int(11) NOT NULL, `update_time` int(11) NOT NULL, `delete_time` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='公司万用描述信息' ``` 带`\G`结尾键值对展示 ## show tables 扩展,显示表注释 SQL: ``` select table_name, table_comment from information_schema.tables where table_schema = '数据库'; ``` 示例: ``` MariaDB [zcsb]> select table_name, table_comment from information_schema.tables where table_schema = 'zcsb'; +------------------------+----------------------------------------------------------------------------------+ | table_name | table_comment | +------------------------+----------------------------------------------------------------------------------+ | zc_preset_reason | 审核预设理由 | | zc_company_description | 公司万用描述信息 | | zc_action_log | 客户信息变更日志表,可作为时间轴的一部分数据 | | zc_userinfo_record | 跟进记录 | | zc_admin_roles | 权限角色表 (organization_range字段对应zj_admin_group_organization的id) | | zc_major_level | 专业级别 | | zc_userinfo | 职称申报 | | zc_education | 教育信息表 | | zc_company | 单位、公司信息 | | zc_major | 技术专业 | | zc_userinfo_audit | 资料审核表 | | zc_major_area | 申报区域 | | zc_work_history | 工作经历 | | zc_achievement | 任现职后主要专业技术工作业绩 | | zc_current_major | 现任专业技术 | | zc_qualification | 职业资格证 | +------------------------+----------------------------------------------------------------------------------+ ```