Enum and set types in mysql

Source: Internet
Author: User


In mysql, The enum and set types in mysql are both string type and can only be set in the specified set. The difference is that set can take multiple values, enum can only take one SQL code CREATE TABLE '192 _ t' ('id' int (11) NOT NULL AUTO_INCREMENT, 'name' varchar (20) NOT NULL, 'cl' set ('x', 'w', 'R') not null, 'c2 'enum ('F', 'D') not null, primary key ('id') ENGINE = InnoDB www.2cto.com insert into 20121101_t values(null,'a.txt ', 'r, W', 'D'); insert into 2012110t t comment', 'r, w', 'f '); For example, add the execution permission to the B .txt file. SQL code update 20121101_t set cl = cl | 1 where id = 2 1 is because the x permission is applied to the first file. For example, remove the write permission from the B .txt file. SQL code update 2012110t t set cl = cl &~ 2 where id = 2 then look at the SQL code select * from 2012110t T 1 a.txt w, r d 2 B .txt x, r f can follow the chmod usage in linux, directly use a number to indicate the permissions. For example, convert B .txt to the read-only SQL code update 2012110t t set cl = 4 where id = 2. For example, you need to find all the SQL code select * from 20121101_t where cl & 4 www.2cto.com or SQL code select * from 2012110t t where FIND_IN_SET ('R ', cl)> 0 enumis relatively simple, such as changing a.txt from a folder to a file SQL code update 201211020.t set c2 = 'F' where id = 1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.