什么更快?
合并声明
MERGE INTO table_name
USING dual
ON (row_id = 'some_id')
WHEN MATCHED THEN
UPDATE SET col_name = 'some_val'
WHEN NOT MATCHED THEN
INSERT (row_id, col_name)
VALUES ('some_id', 'some_val')
或者
查询 select 语句,然后使用 update 或 insert 语句。
SELECT * FROM table_name where row_id = 'some_id'
如果行数 == 0
INSERT INTO table_name (row_id,col_name) VALUES ('some_id','some_val')
别的
UPDATE table_name SET col_name='some_val' WHERE row_id='some_id'