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;
总结: