For 255 to 65,535 members, 2 bytes of storage are required. Up to 65,535 members are allowed.
A data table with enumerated types is created first through the SQL statement.
| The code is as follows |
Copy Code |
CREATE TABLE User_sex (Sex enum (' M ', ' F '));
|
Write a few more test data to the table:
INSERT into user_sex values (' M '), (' s '), (' 2 '), (' F ');
When you view the results of a write in a table, the discovery becomes such a m,m,m,f (note that each character is a record). It is known from the result that the enum type is case-insensitive, and that ' F ' is automatically converted to ' F ', forcing the first value (M) to be written to the enumeration when it writes a value that is not in the specified range. In addition, the enum type selects only a single value from the Fill collection and cannot fetch multiple values.
Enum Test Summary
n Enum type enum
a). database table Mysqlops_enum Structure
Execute the SQL statement created by the database table Mysqlops_enum:
Assumption table: There is a field in XXX The folder type is enum (' Inbox ', ' Outbox ', ' other ')
Save
| The code is as follows |
Copy Code |
insert INTO ' xxx ' (' folder ') VALUES (' Inbox '); insert INTO ' xxx ' (' folder ') VALUES (' Outbox '); insert INTO ' xxx ' (' folder ') VALUES (' other '); |
Update
| The code is as follows |
Copy Code |
Update ' xxx ' set ' folder ' = ' Inbox '; Update ' xxx ' set ' folder ' = ' Outbox '; Update ' xxx ' set ' folder ' = ' other '; |
Delete
| The code is as follows |
Copy Code |
Delete from ' xxx ' where ' folder ' = ' Inbox '; Delete from ' xxx ' where ' folder ' = ' Outbox '; Delete from ' xxx ' where ' folder ' = ' other '; |
The enum type is defined so that the action is the same as a string
For more details please see: http://www.111cn.net/database/mysql/38235.htm