需要更新十几张表,所表里所有值的空格给去掉.一个个写字段名太麻烦了,就自己写了个,不知道对不对,哈哈,错了请指出来啊.
SELECT 'update &table_name set '||
ltrim(sys_connect_by_path(column_name||'= trim('||column_name||')', ','),',')||';', LEVEL
FROM (SELECT column_name, COUNT(column_name)over() cnt, ROWNUM rn
FROM USER_TAB_COLUMNS t
WHERE table_name = '&table_name'
) A
WHERE LEVEL = cnt
START WITH A.RN=1
CONNECT BY RN = PRIOR RN + 1;
ltrim(sys_connect_by_path(column_name||'= trim('||column_name||')', ','),',')||';', LEVEL
FROM (SELECT column_name, COUNT(column_name)over() cnt, ROWNUM rn
FROM USER_TAB_COLUMNS t
WHERE table_name = '&table_name'
) A
WHERE LEVEL = cnt
START WITH A.RN=1
CONNECT BY RN = PRIOR RN + 1;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24478467/viewspace-714769/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24478467/viewspace-714769/