How to use enumeration type in mysql

How to use the enumeration type in mysql: 1. Insert data, the syntax is [insert into my_enum values ​​(1), (2);]; 2. Error data, the syntax is [insert into my_enum values( & # 39; male & # 39;);]. Related learning recommendation: mysql tutorial How to use the enumeration type in mysql: Enumeration: enum, to achieve all possible results are designed, in fact, the stored data must be one of the specified data. How to use enumeration Definition: enum (list of possible elements); such as enum (‘male’ ,’female’) Use: store data, only the data defined above can be stored The meaning lies in: 1, the possibility of limiting the value! 2, fast, faster than ordinary strings! The reason is that the enumeration type is managed by integers, which can be managed by 2 bytes! Each value is an integer identifier, starting from the first option as 1, increasing one by one! Management in the form of integers, faster than strings! There are 2 bytes in total, 0-65535, so there are 65535 options available! 、 Create enumeration table create table my_enum( gender enum(‘Male’, ‘Male’, ‘Female’, ‘Confidential’) )charset utf8; The first function: standardize the data format, the data can only be one of the…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索