今晚我最得意之作——利用Oracle超级无敌强大函数生成“批量生成数据语句”!

语句一:

 

select rownum, a.*
  from (select t.brand_name, wm_concat(t.pd_type), wm_concat(t.brand_id)
          from base_brand t
         group by t.brand_name) a

语句二:

select 'insert into BASE_BRAND_INFO(BRAND_ID, BRAND_NAME, BRAND_NAME_CN) values(' ||
       rownum || ',''' || a.brand_name || ''',''' || a.brand_name || ''');'
  from (select t.brand_name, wm_concat(t.pd_type), wm_concat(t.brand_id)
          from base_brand t
         group by t.brand_name) a

语句三:

 

select 'update BASE_BRAND set BRAND_ID=' || rownum || ' where BRAND_ID in (' || a.BRAND_IDS || ');'
  from (select t.brand_name, wm_concat(t.pd_type), wm_concat(t.brand_id) BRAND_IDS
          from base_brand t
         group by t.brand_name) a

最后:

 

准确!高效!简单!完美!

posted @ 2009-12-19 20:14  笑的自然  阅读(205)  评论(0编辑  收藏  举报