Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set default in MySQL database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces you how to set default in the MySQL database, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. Table-building script

CREATE TABLE `test` (`uid` varchar (32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `USER_ code `CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'user code', `LEAVE_ REASON` varchar''COMMENT' reason for leave', PRIMARY KEY (`uid`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic

two。 View column definition

SELECT c.TABLE_SCHEMA 'database', c.TABLE_NAME 'table', c.COLUMN_NAME 'field', c.COLUMN_DEFAULT 'default', c.IS_NULLABLE 'empty', c.DATA_TYPE 'field type', c.character_set_name 'character set', c.collation_name 'collation' FROM information_ schema.`COLUMNS`c WHERE TABLE_NAME = 'test'

Here we can find that default is set to NULL and default is not set in the information_ schema.`COLUMNS` table both appear as NULL. If our script can easily judge from this, it conflicts with whether it is empty or not.

3. Observe from navicat

If you look at the table definition directly from navicat, you can find different performance.

On how to set up default in the MySQL database to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report