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

What does the enumeration in the MySQL field refer to

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

Share

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

This article mainly explains "what the enumeration in the MySQL field refers to". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what the enumeration in the MySQL field refers to".

What does the enumeration in the MySQL field mean?

Mysql > createtablemeiju (f1enum ('1th, 2nd, 3rd, 4th, 5th, 6th))

QueryOK,0rowsaffected (0.92sec)

Mysql > descmeiju

+-- +

| | Field | Type | Null | Key | Default | Extra | |

+-- +

| | F1 | enum ('1, NULL, 3, 4, 5, 6) | YES | | NULL | |

+-- +

Mysql > insertintomeijuvalues (2)

Mysql > insertintomeijuvalues ("2")

Mysql > insertintomeijuvalues ("6")

The serial number is 12345

The content cannot be inserted without a serial number or a serial number.

Mysql > insertintomeijuvalues (8)

ERROR1265 (01000): Datatruncatedforcolumn'f1'atrow1

Mysql > insertintomeijuvalues ("8")

ERROR1265 (01000): Datatruncatedforcolumn'f1'atrow1

Mysql > select*frommeiju

+-+

| | F1 |

+-+

| | 1 |

| | 2 |

| | 2 |

| | 6 |

+-+

Change the meter

Mysql > altertablemeijumodifyf1enum ("a", "b", "c", "d", "e", "f")

QueryOK,4rowsaffected (0.39sec)

Records:4Duplicates:0Warnings:0

You can automatically match the record as a serial number to a new field value (amazing)

Mysql > select*frommeiju

+-+

| | F1 |

+-+

| | a |

| | b |

| | b |

| | f |

+-+

What does the enumeration in the MySQL field mean?

A record can have only one enumerated value, unlike set, which can be accumulated.

Mysql > insertintomeijuvalues (7)

ERROR1265 (01000): Datatruncatedforcolumn'f1'atrow1

Note that it is best to enter a worthwhile value in quotation marks or it will be treated as a sequence number.

When the quoted number does not meet the enumeration requirements, it will try to see if it is appropriate to use it as a sequence number.

Such as insertintomeijuvalues ("7")

7 insert the seventh value if it is not in the enumerated value. If there are no 7 values, an error will be reported.

The difference between collections and enumerations

1 collection can have 64 values enumerate 65535

The serial number of the collection is 124816 and the enumeration is 123456.

3 set A field value can have several values

+-+

| | F1 |

+-+

| | fpen m |

+-+

There can be only one enumeration.

Thank you for your reading, the above is the content of "what does the enumeration in the MySQL field refer to". After the study of this article, I believe you have a deeper understanding of what the enumeration in the MySQL field refers to, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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