当前位置:网站首页>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 .
边栏推荐
- B站大佬用我的世界搞出卷積神經網絡,LeCun轉發!爆肝6個月,播放破百萬
- Project duplicate template
- Huawei cloud gaussdb (for redis) unveils issue 21: using Gauss redis to achieve secondary indexing
- 食品里的添加剂品种越多,越不安全吗?
- 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.
- docker启动mysql及-eMYSQL_ROOT_PASSWORD=my-secret-pw问题解决
- 存币生息理财dapp系统开发案例演示
- docker mysql5.7如何设置不区分大小写
- Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
- js导入excel&导出excel
猜你喜欢

动作捕捉用于蛇运动分析及蛇形机器人开发

为了交通安全,可以做些什么?

(1)长安链学习笔记-启动长安链

UE4 blueprint learning chapter (IV) -- process control forloop and whileloop

Word2vec (skip gram and cbow) - pytorch
MySQL实现字段分割一行转多行的示例代码

监控界的最强王者,没有之一!

Up to 5million per person per year! Choose people instead of projects, focus on basic scientific research, and scientists dominate the "new cornerstone" funded by Tencent to start the application

None of the strongest kings in the monitoring industry!

ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
随机推荐
(shuttle) navigation return interception: willpopscope
The application of machine learning in software testing
NFTScan 开发者平台推出 Pro API 商业化服务
Modules that can be used by both the electron main process and the rendering process
同一个作业有两个source,同一链接不同数据库账号,为何第二个链接查出来的数据库列表是第一个账号的
Redis persistence mechanism
基于PaddlePaddle平台(EasyDL)设计的人脸识别课堂考勤系统
CSDN 上传图片取消自动加水印的方法
TDengine 社区问题双周精选 | 第二期
Improving Multimodal Accuracy Through Modality Pre-training and Attention
Introduction to network basics
COSCon'22 社区召集令来啦!Open the World,邀请所有社区一起拥抱开源,打开新世界~
Let's see through the network i/o model from beginning to end
Case recommendation: An Qing works with partners to ensure that the "smart court" is more efficient
#DAYU200体验官# 首页aito视频&Canvas绘制仪表盘(ets)
spark调优(二):UDF减少JOIN和判断
A few suggestions for making rust library more beautiful! Have you learned?
Thinkphp5 multi table associative query method join queries two database tables, and the query results are spliced and returned
同构+跨端,懂得小程序+kbone+finclip就够了!
ICLR 2022 | pre training language model based on anti self attention mechanism