zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

SQLite 基础15

2023-03-20 15:36:52 时间

DELETE

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

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的规则 用* 替代 % 替代 _

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>