Oracle 中的 ORDER BY 和 SORT 函數都用于對查詢結果進行排序,但它們之間存在一些關鍵區別:
SELECT * FROM employees
ORDER BY salary DESC, hire_date ASC;
DECLARE
TYPE num_array IS TABLE OF NUMBER;
numbers num_array := num_array(3, 1, 4, 1, 5, 9);
BEGIN
numbers := SORT(numbers);
FOR i IN 1..numbers.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(numbers(i));
END LOOP;
END;
總結: