Get the App
SLTechnology News&Howtos  ›  Database  › 

What does the enumeration in the MySQL field refer to

Shulou Source: shulou.com Published: 2022-05-31 19:14:33 10月25日 Update

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!

Tags: Fields serial numbers content learning fit quotation marks meaning magic will try that is ideas situations numbers articles times more best knowledge knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft Linux NVidia Xiaomi