1、在对表做插入操作是,若数据已存在可以用 replace 更新数据:insert or replace into....;若不希望更新数据,则使用ignore忽略数据:insert or ignore into....
2、可以从一个表中投影出数据插入到另一张表中。insert into 表1 select 列1,列2 from 表2;
3、可以在一条插入语句中,一次性插入多条数据,用‘,’分开。
4、创建(唯一)索引:create (unique) index xxx on 表(列)
5、创建视图:create view 视图名 as select 列... from 表名
6、replace两种用法:插入时若记录存在,更新字段,replace into 表名 (字段) VALUES(值);replace(object,search,replace),把object对象中出现的的search全部替换成replace。
7、重命名表:SQLite3,alter table 表名1 reanme to 表名2;mysql:rename table 表名1 to 表名2;oracle:rename 表名1 to表名2;
8、可以对分组后的字段进行合并:GROUP_CONCAT(字段)。
9、exists关键字的使用:select * from A where exists (select * from B where B.id = A.id);等价于select * from A where A.id in (select id from B);
10、