查询DUAL表和UNION ALL

时间:2017-11-01 10:38:19

标签: sql oracle

我有如下查询,

 SELECT 1 AS SI, 'JAN' AS MoN FROM DUAL
 UNION ALL
 SELECT 2, 'FEB' FROM DUAL
 UNION ALL
 SELECT 3, 'MAR' FROM DUAL
 UNION ALL
 SELECT 4, 'APR' FROM DUAL
 UNION ALL
 SELECT 5, 'MAY' FROM DUAL
 UNION ALL
 SELECT 6, 'JUN' FROM DUAL
 UNION ALL
 SELECT 7, 'JUL' FROM DUAL
 UNION ALL
 SELECT 8, 'AUG' FROM DUAL
 UNION ALL
 SELECT 9, 'SEP' FROM DUAL
 UNION ALL
 SELECT 10, 'OCT' FROM DUAL
 UNION ALL
 SELECT 11, 'NOV' FROM DUAL
 UNION ALL
 SELECT 12, 'DEC' FROM DUAL ;

请您在此处协助任何最佳替代方案或任何性能改进吗?

1 个答案:

答案 0 :(得分:3)

试试吧

SELECT
  LEVEL AS ID,
  TO_CHAR(ADD_MONTHS(DATE '1000-01-01', LEVEL-1), 'MON') 
FROM DUAL 
CONNECT BY LEVEL <= 12;