SQLite 基础15

2021-12-01 17:31:13 浏览数 (2)

DELETE

代码语言:javascript复制
sqlite> select * from company where id=7;
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
7           James       24          test        10.0      
sqlite> delete from company where id=7;
sqlite> select * from company where id=7;
sqlite> select * from company;
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
1           Paul        32          test        10.0      
2           Allen       25          test        10.0      
3           Teddy       23          test        10.0      
4           Mark        25          test        10.0      
5           David       27          test        10.0      
6           Kim         22          test        10.0      
sqlite> delete from company;
sqlite> select * from company;
sqlite>

LIKE

代码语言:javascript复制
sqlite> select * from company where age like '%5';
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
2           Allen       25          Texas       15000.0   
4           Mark        25          Rich-Mond   65000.0   
sqlite> 
sqlite> select * from company where address like '%-%';
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
4           Mark        25          Rich-Mond   65000.0   
6           Kim         22          South-Hall  45000.0   
sqlite> 

GLOB

GLOB与LIKE类似,都是用来进行模糊匹配的,但是通配符使用的shell的规则 用* 替代 % 替代 _

代码语言:javascript复制
sqlite> select * from company where age glob '*5';
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
2           Allen       25          Texas       15000.0   
4           Mark        25          Rich-Mond   65000.0   
sqlite> select * from company where address glob '*-*';
id          name        age         address     salary    
----------  ----------  ----------  ----------  ----------
4           Mark        25          Rich-Mond   65000.0   
6           Kim         22          South-Hall  45000.0   
sqlite>
sqlite> select * from company where age glob '%5';
sqlite>

0 人点赞