当前位置:网站首页>Summary of three methods for MySQL to view table structure
Summary of three methods for MySQL to view table structure
2022-07-06 23:19:00 【1024 questions】
mysql View table structure
1. show create table
2. desc
3. information_schema.COLUMNS
Get all the table structures and comments
Export all table information according to the library name
Export all table names and table comments according to the library name
mysql Get all tables of the entire library , And table structure
mysql View table structure 1. show create tableshow create table The name of the table This sentence comes up instinctively every time , Semantic memorization , You can directly view the table creation statement , But it is not convenient for code processing .
2. descdesc The name of the table This statement is easy to use , Can be obtained COLUMNS The more important fields in : name 、 type 、 Is it empty 、 key 、 The default value is 、 Additional information . But cannot get the comment of the field .
3. information_schema.COLUMNSselect * from information_schema.COLUMNS where TABLE_SCHEMA = ' Library name ' and TABLE_NAME = ' The name of the table 'relative show create table for , Relatively simple , Comprehensive information , You can query the name of the field 、 type 、 key 、 jurisdiction 、 Notes and other information . To get the field name , So I use this as a method to get the table structure in my script .
attach :information_schema.COLUMNS Fields and meanings
Field name and meaning
TABLE_CATALOG Table type ( I didn't understand what to do ?)
TABLE_SCHEMA Library name
TABLE_NAME The name of the table
COLUMN_NAME Field name
ORDINAL_POSITION Location number
COLUMN_DEFAULT The default value is
IS_NULLABLE Can it be empty
DATA_TYPE data type
CHARACTER_MAXIMUM_LENGTH Maximum string length ( The value type is empty )
CHARACTER_OCTET_LENGTH Maximum storage length of string ( It is generally the same as the previous field )
NUMERIC_PRECISION Numerical accuracy ( Non numeric type is empty )
NUMERIC_SCALE Number of decimal places ( Non numeric type is empty )
DATETIME_PRECISION Date precision
CHARACTER_SET_NAME Encoding mode
COLLATION_NAME sort order
COLUMN_TYPE Field type
COLUMN_KEY Fields involved key( Primary key 、 Unique key, etc )
EXTRA other ( Such as auto_increment)
PRIVILEGES jurisdiction
COLUMN_COMMENT Annotation fields
GENERATION_EXPRESSION Represents the expression ( I don't understand ,mysql Table inheritance ?)
SELECT *FROM information_schema.`TABLES`WHERE TABLE_SCHEMA = 'db_name' Export all table names and table comments according to the library name SELECT TABLE_NAME, TABLE_COMMENTFROM information_schema.`TABLES`WHERE TABLE_SCHEMA = 'db_name';mysql Get all tables of the entire library , And table structure SELECT TABLE_SCHEMA AS ' Library name ', TABLE_NAME AS ' Table name ', COLUMN_NAME AS ' Name ', ORDINAL_POSITION AS ' Order of columns ', COLUMN_DEFAULT AS ' The default value is ', IS_NULLABLE AS ' Is it empty ', DATA_TYPE AS ' data type ', CHARACTER_MAXIMUM_LENGTH AS ' Maximum character length ', NUMERIC_PRECISION AS ' Numerical accuracy ( Maximum number )', NUMERIC_SCALE AS ' Decimal precision ', COLUMN_TYPE AS ' Column type ', COLUMN_KEY 'KEY', EXTRA AS ' Additional instructions ', COLUMN_COMMENT AS ' notes 'FROM information_schema.`COLUMNS`WHERE TABLE_SCHEMA = 'db_name'ORDER BY TABLE_NAME, ORDINAL_POSITION;The above is personal experience , I hope I can give you a reference , I also hope you can support the software development network .
边栏推荐
- The problem that dockermysql cannot be accessed by the host machine is solved
- Station B Big utilise mon monde pour faire un réseau neuronal convolutif, Le Cun Forward! Le foie a explosé pendant 6 mois, et un million de fois.
- 欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质
- 使用MitmProxy离线缓存360度全景网页
- DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
- PDF批量拆分、合并、书签提取、书签写入小工具
- 专为决策树打造,新加坡国立大学&清华大学联合提出快速安全的联邦学习新系统
- docker启动mysql及-eMYSQL_ROOT_PASSWORD=my-secret-pw问题解决
- Docker mysql5.7 how to set case insensitive
- koa2对Json数组增删改查
猜你喜欢

js對JSON數組的增删改查

MySQL connected vscode successfully, but this error is reported
Docker starts MySQL and -emysql_ ROOT_ Password = my secret PW problem solving

室内LED显示屏应该怎么选择?这5点注意事项必须考虑在内

同构+跨端,懂得小程序+kbone+finclip就够了!

Ajout, suppression et modification d'un tableau json par JS

每人每年最高500万经费!选人不选项目,专注基础科研,科学家主导腾讯出资的「新基石」启动申报...

欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质

Flutter life cycle

Children's pajamas (Australia) as/nzs 1249:2014 handling process
随机推荐
Nftscan Developer Platform launches Pro API commercial services
js對JSON數組的增删改查
Dayu200 experience officer runs the intelligent drying system page based on arkui ETS on dayu200
Dockermysql modifies the root account password and grants permissions
Some suggestions for foreign lead2022 in the second half of the year
CSDN 上传图片取消自动加水印的方法
MySQL数据库之JDBC编程
Redis 持久化机制
前置机是什么意思?主要作用是什么?与堡垒机有什么区别?
Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
Bipartite graph determination
On file uploading of network security
存币生息理财dapp系统开发案例演示
DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
基于PaddlePaddle平台(EasyDL)设计的人脸识别课堂考勤系统
AcWing 4299. Delete point
A few suggestions for making rust library more beautiful! Have you learned?
不要再说微服务可以解决一切问题了
mysql拆分字符串作为查询条件的示例代码
OpenSSL: a full-featured toolkit for TLS and SSL protocols, and a general encryption library