Mysql get table comment field operation

Mysql get table comment field operation

I won't say much nonsense, let's just look at the code~

-- View and obtain the field comments in the table:
show full columns from tablename;
-- Or show full fields from tablename;
-- Or, look in the metadata table Select COLUMN_NAME column name, DATA_TYPE field type, COLUMN_COMMENT field comment from INFORMATION_SCHEMA.COLUMNS
Where table_name = 'companies'##table name AND table_schema = 'testhuicard'##database name AND column_name LIKE 'c_name'##field name -- 2-1 How to view table comments:
show create table tablename;
-- 2-2 Get all table information of the entire database (including table name, table comment, table type, etc.):
SELECT table_name, table_type, engine
FROM information_schema.tables
WHERE table_schema = 'db5' //table_schema is the database name ORDER BY table_name DESC;
-- This statement requests a reverse alphabetical listing of all tables in database db5, but only displays three types of information: table name, table type, and table engine.
-- INFORMATION_SCHEMA is the information database that holds information about all other databases maintained by the MySQL server.
SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'sh_goods' AND TABLE_SCHEMA = 'sh_shop'; //Get the comments of the sh_goods table in the sh_shop database.
-- 2-3 Get table comments or -- or use:
show table status;
-- Comment is a table comment.
-- Extensions:
-- Modify the table's comments:
alter table test1 comment 'Comments of the modified table';
-- Modify the field's comment:
alter table test1 modify column field_name int comment 'modified field comment';

Supplement: mysql query all field names, field types and comments of a table in a database

When doing background development, we must generate corresponding entity classes, that is, JavaBeans, from the tables in the data. During development, in order to quickly generate entity classes, we can query all field names, field types and comments of a table in the database, and quickly create JavaBeans, which can also prevent spelling errors.

Corresponds one to one with the fields in the database. In Navicat (database visualization tool), you can execute SQL statements

select COLUMN_NAME,DATA_TYPE,COLUMN_COMMENT from information_schema.COLUMNS where table_name = 'table name' and table_schema = 'database name';

The result is similar to:

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • MySQL table and column comments summary
  • Basic operations of MySQL data tables: table structure operations, field operation example analysis
  • MySql creates a table with explanation and annotates the table and fields

<<:  How to use VUE to call Ali Iconfont library online

>>:  HTML table tag tutorial (20): row background color attribute BGCOLOR

Recommend

Implementing carousel effects with JavaScript

This article shares the specific code for JavaScr...

Summary of how JS operates on pages inside and outside Iframe

Table of contents Get the content of the iframe o...

Introduction to HTML basic controls_PowerNode Java Academy

The <input> tag The <input> tag is us...

Detailed explanation of TIMESTAMPDIFF case in MySQL

1. Syntax TIMESTAMPDIFF(unit,begin,end); Returns ...

Use Nginx to build a streaming media server to realize live broadcast function

Written in front In recent years, the live stream...

vue+element-ui implements the head navigation bar component

This article shares the specific code of vue+elem...

mysql-8.0.16 winx64 latest installation tutorial with pictures and text

I just started learning about databases recently....

How to write the Nofollow tag and how to use it

The "nofollow" tag was proposed by Goog...

Solution to Vue data assignment problem

Let me summarize a problem that I have encountere...

Vue-cli creates a project and analyzes the project structure

Table of contents 1. Enter a directory and create...

MySQL Index Detailed Explanation

Table of contents 1. Index Basics 1.1 Introductio...

HTML realizes real-time monitoring function of Hikvision camera

Recently the company has arranged to do some CCFA...

CSS3 to achieve menu hover effect

Result: html <nav id="nav-1"> <...