一、mysql中:
INSERT INTO test_table(path, username, description) VALUES ('/root/test', 'zhangsan', 'this is test')
ON DUPLICATE KEY UPDATE path = '/root/test', username = 'zhangsan', description = 'this is test'
二、orcale中:
merge into test_table t1
using (select 'zhangsan' username,'/root/test' path, 'this is test' description from dual) t2
on (t1.path = t2.path)
when matched then
update set t1.path = t2.path, t1.username = t2.username, t1.description = t2.description
when not matched then
insert (path, username, description) values (t2.path, t2.username, t2.description)