经验总计05-一些特殊的sql语句

开发中往往需要一些简单的sql语句进行一些数据库处理。

把分组数据合并在一起:select groupname,wmsys.wm_concat(name) from tablename group by code;

oracle获取序列的下一个值:select mySeq.nextVal from dual;

对比更新:merge into table1 a using table2 b on (a.id=b.id)  

when matched then update (a.name=b.name)

when not matched then insert values(a.name=b.name);

字符串连接:select concat(a.name,a.name2) from table a;

select a.name ||' '|| a.name2 from table a;

select a.name '+' a.name2 from table a;

如果遇到一些特殊的需求,可搜索下,有可能有合适的sql语句就可以满足你的功能。

posted @ 2014-05-28 20:13  moonL  阅读(135)  评论(0编辑  收藏  举报