当前位置:网站首页>Can you view MySQL data table structure in two ways?
Can you view MySQL data table structure in two ways?
2022-07-19 12:40:00 【Operation and maintenance home】
Teach you how to view the data table structure
After we create the table , How to view the table structure , In order to confirm that the table meets our expectations , We can use
describeperhapsshow create tableOrder to seemysqlData table structure , Now let's look at the specific usage .
1、describe grammar
DESCRIBE/DESC Statement can view the field information of the table , This includes the field name 、 Field data type 、 Is it a primary key 、 Whether there are default values, etc .
grammar :
DESCRIBE Table name
We usually abbreviate it as :
DESC Table name
Let's take a look at the newly created table , Let's take a specific look at the content of each meaning ;
mysql> describe test_user;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int | YES | | NULL | |
| name | varchar(25) | YES | | NULL | |
| deptid | int | YES | | NULL | |
| money | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> desc test_user;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int | YES | | NULL | |
| name | varchar(25) | YES | | NULL | |
| deptid | int | YES | | NULL | |
| money | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql>
We can see that no matter what we use describe still desc Command to view the table structure , The results are consistent .
Then look at the specific information :
Fiels: Field nameType: Field typeNull: Whether it can be nullKey: Is there an index ;PRIIndicates that it is part of the primary key ;UNIIndicates that the column isUNIQUEPart of index ;MULIndicates that a given value is allowed to appear more than onceDefault: The default value isExtra: Represents additional information about a given column that can be obtained
2、show create table grammar
show create table You can view the specific statement of creating the table ;
grammar :
show create table < Table name \G>
Use
SHOW CREATE TABLEsentence , You can not only view the detailed statements when creating the table , You can also view the storage engine and character encoding .\GParameters are equivalent to formatted output , Make its output content more readable .
Example :
mysql> show create table test_user;
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
|
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| test_user | CREATE TABLE `test_user` (
`id` int DEFAULT NULL COMMENT ' Employee number ',
`name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ' Employee name ',
`deptid` int DEFAULT NULL COMMENT ' Department number ',
`money` float DEFAULT NULL COMMENT ' Wages '
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
If you add \G after , We can see that the output content is highly readable ;
mysql> show create table test_user\G;
*************************** 1. row ***************************
Table: test_user
Create Table: CREATE TABLE `test_user` (
`id` int DEFAULT NULL COMMENT ' Employee number ',
`name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ' Employee name ',
`deptid` int DEFAULT NULL COMMENT ' Department number ',
`money` float DEFAULT NULL COMMENT ' Wages '
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
1 row in set (0.00 sec)
ERROR:
No query specified
mysql>
Support , In this paper, the end .
For more information, go to VX official account “ Operation and maintenance home ” , Get the latest article .
------ “ Operation and maintenance home ” ------
------ “ Operation and maintenance home ” ------
------ “ Operation and maintenance home ” ------
Interview with system operation and maintenance engineer , Nominations for excellent staff of operation and maintenance engineer ,tr O & M Engineer , I'm calling the operation and maintenance engineer for daily work ,IT Senior operation and maintenance engineer ;
Intelligent manufacturing operation and maintenance engineer training course , Remote office operation and maintenance engineer , Salary of Mindray medical operation and maintenance engineer , What does the backstage O & M engineer do ;
How about the wind operation and maintenance engineer , Inspur cloud operation and maintenance engineer , Sample certificate of medical equipment operation and maintenance engineer , Boyfriend of operation and maintenance engineer , The O & M engineer is grumpy .
边栏推荐
猜你喜欢

Will the market halve? What investment opportunities are there? 2020-03-11

Ultrasonic sensor (chx01) learning notes Ⅲ - I2C reading and writing operation

How to apply applet container technology to develop hybrid app

Machine learning Assignment 1

云犀聚焦店播解决方案,加速全球化布局

Leetcode 150. Evaluation of inverse Polish expression

Learning record: call TFTLCD

C#从入门到精通之第一篇: C#概述与入门

OpenCV基于DLCO描述子匹配

超声波传感器(CH101&ch201) - Ⅰ
随机推荐
Softmax和Cross-entropy是什么关系?
Ultrasonic sensor (ch101 & ch201) - Ⅱ
Ah Qu's thinking
mysql中对于数据库的基本操作
查看mysql数据表结构的两种方法你会吗?
35岁以上的测试/开发程序员职业生涯走向,是职场转折点吗?
Knowledge sorting of MySQL
Return to risk ratio: the most important indicator of investment opportunities 2020-03-14
第四天作业
ATT&CK实战系列——红队实战(—)
Review the 2008 financial crisis and become a long-term investor 2020-03-19
Useeffect summary
2022-07-07:Spire. Office 7.7.2 for net debuted
Opencv based on DLCO descriptor matching
Learning record: call TFTLCD
Machine learning Assignment 1
超声波传感器系列文章汇总
mycat 根据字符串范围hash值分库分表
Committer identity unknown *** Please tell me who you are...
Harmonyos quick start: Hello World