SELECT column_name
FROM user_tab_cols
WHERE table_name=UPPER('TABLE名字')
order by column_id
如果要變一行 用「,」分隔
↓只適用11up
SELECT LISTAGG(column_name, ',') WITHIN GROUP (ORDER BY column_id)
FROM user_tab_cols
WHERE table_name=UPPER('TABLE名字')
↓9 10
SELECT LTRIM(MAX(SYS_CONNECT_BY_PATH(column_name,',')) KEEP (DENSE_RANK LAST
ORDER BY curr),',') AS employees
FROM
(SELECT column_name, ROW_NUMBER() OVER ( ORDER BY column_id) AS curr, ROW_NUMBER() OVER ( ORDER BY column_id) -1 AS prev
FROM user_tab_cols
WHERE table_name=UPPER('TABLE名字')
)
CONNECT BY prev = PRIOR curr
START WITH curr = 1;
另外補充撈出 table 欄位大概資料(型態 是否null size)
DESCRIBE TABLE名字
沒有留言:
張貼留言