程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql中的enum和set類型

mysql中的enum和set類型

編輯:MySQL綜合教程


mysql中的enum和set類型   mysql中的enum和set其實都是string類型的而且只能在指定的集合裡取值,  不同的是set可以取多個值,enum只能取一個  Sql代碼   CREATE TABLE `20121101_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 20121101_t   values(null,'b.txt','r,w','f');     比如給b.txt文件加上執行權限  Sql代碼   update 20121101_t set cl = cl|1 where id =2     1是因為x權限出現在了第一個    再比如給b.txt文件去掉寫權限  Sql代碼   update 20121101_t set cl = cl&~2 where id =2     這時再看  Sql代碼   select * from 20121101_t     1 a.txt w,r d  2 b.txt x,r f    可以仿照linux下chmod的用法,直接用數字表示權限  比如把b.txt變成只讀  Sql代碼   update 20121101_t set cl = 4 where id =2     比如要找到所有包含了讀權限的文件  Sql代碼   select * from 20121101_t where cl&4     www.2cto.com   或者  Sql代碼   select * from 20121101_t where FIND_IN_SET('r',cl)>0     enum就相對簡單了,比如把a.txt從文件夾變成文件  Sql代碼   update 20121101_t set c2 = 'f' where id =1    

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved