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

Char (n) of the database

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Char (n) or varchar (n) in Mysql, where n represents a column, not bytes!

Varchar (n), where n is at most 65535, should specify that the table is encoded as latin1 when the table is created, because one character in latin1 accounts for 1 byte. In this 65535, there are 2 bytes to store the length of the contents of the column. There is also a byte to store the null value! So there are 65532 bytes left.

Auto_increment automatic growth constraint.

Note that you can't just add a self-growing constraint to a column. To add self-growing, the column must first be a key (primary key constraint or uniqueness constraint).

At this point, when we add data, we don't have to add id, because id will grow on its own!

As you can see, since self-growth, the default is to increase from 1, each increase of 1, these values can be modified.

The type of self-growing column must be a numeric type.

In fact, let id column self-growth, do not have to write down the name of the column, this is too troublesome!

You can define the starting value of self-growth.

1. Colleagues in the definition table specify:

two。 After the table is created, modify the starting value since the growth

Note that this starting value can be modified larger than the current maximum. It will start to grow from the new starting value!

We will now delete the data from the table. Add the data again, and the resulting self-increasing value is followed by the maximum retention value!

Truncate table deletes the table before creating it. (technically called "truncation" table)

The role of the truncated table allows the self-growing column to re-generate the value from the starting value!

Note that after deleting an id, the following id will not "squeeze up"

Uniqueness constraint: the value of the column to which the uniqueness constraint is added cannot be repeated. Unlike a primary key, the value of a uniqueness constraint can be NULL, and there can be multiple uniqueness constraints in a table.

Note that the column of a uniqueness constraint can have null values and multiple null values.

Yi Yue (Shenzhen) Technology Co., Ltd.

Make happiness easier.

Wechat: EJoyYOJOY

Weibo: http://weibo.com/EJoyYOJOY

Official website: http://www.ejoytec.com/

Contact & contribution: service@ejoytec.com

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