Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of querying all fields of table words in mysql

Shulou Source: shulou.com Published: 2022-06-01 02:54:59 10月04日 Update

Editor to share with you the method of querying all fields of table words in mysql. I hope you will gain a lot after reading this article. Let's discuss it together.

Mysql query table word all fields method: use "SHOW FROM" statement with FULL keyword to query, syntax "SHOW FULL COLUMNS FROM table_name", you can display all the field information of the specified data table.

Mysql query table word all fields

1. View all table names:

Show tables [from db_name]

2. View field information

SHOW FULL COLUMNS FROM table_name

Get the following information

Field: field name

Type: field typ

Collation: character set (mysql 5.0 or above)

Null: whether it can be NULL

Key: index (PRI,unique,index)

Default: default

Extra: extra (auto_increment or not)

Privileges: permission

Comment: remarks (mysql 5.0 or above)

Mysql > create table teacher # create teacher Table-> (- > Id int (5) auto_increment not null primary key,-> name char (10) not null,-> address varchar (50) default 'No.1 Mid school',-> year date->); Query OK, 0 rows affected (0.02 sec) mysql > show tables +-+ | Tables_in_school | +-+ | teacher | +-+ 1 row in set (0.00 sec) mysql > show full columns from teacher # display all fields of teacher table +-+- -+-+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-- -+-- +-+ | Id | int (5) | NULL | NO | PRI | NULL | auto_increment | select Insert,update,references | name | char (10) | latin1_swedish_ci | NO | | NULL | | select,insert,update,references | | address | varchar (50) | latin1_swedish_ci | YES | | No.1 Mid school | | select,insert,update References | | year | date | NULL | YES | | NULL | | select,insert,update References | | +-- -+-+ 4 rows in set (0.01sec) mysql > drop table teacher # delete teacher table Query OK, 0 rows affected (0.03 sec) mysql > show tables;Empty set (0.00 sec) mysql > after reading this article, I believe you have a certain understanding of mysql query table word all fields, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

Tags: Fields queries table words methods information articles keywords keywords remarks characters character sets done data datasheets more permissions knowledge types indexes industries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info Xiaomi NVidia Shulou Information