1. 程式人生 > >資料庫SQL實踐35:批量插入資料,不使用replace操作

資料庫SQL實踐35:批量插入資料,不使用replace操作

思路:

SQLite如果不存在則插入,如果存在則忽略

INSERT OR IGNORE INTO tablename VALUES(...);

如果不存在則插入,如果存在則替換

INSERT OR REPLACE INTO tablename VALUES(...);

這裡指的存在表示的是unique屬性的列值存在的情況下,unique表示鍵值唯一

mysql 去掉or

insert or ignore into actor values(3,"ED","CHASE","2006-02-15 12:34:33");