我希望 postgreSQL 中的显示顺序与 oracle 输出中生成的显示顺序相同。我尝试使用下面显示的以下 oracle 查询和输出
create table student(
std_id int, std_roll int
);
SELECT std_id, std_roll
FROM student
CONNECT BY PRIOR std_id = std_roll;
预言机输出
对应的postgreSQL查询和输出
create table student(
std_id int, std_roll int
);
INSERT into student values( 1, 0 );
INSERT into student values( 2, 1 );
INSERT into student values( 3, 1 );
INSERT into student values( 4, 2 );
INSERT into student values( 5, 2 );
INSERT into student values( 6, 3 );
INSERT into student values( 7, 4 );
WITH RECURSIVE q AS (
SELECT po.std_id,po.std_roll
FROM student po
UNION ALL
SELECT po.std_id,po.std_roll
FROM student po
JOIN q ON q.std_id=po.std_roll
)
SELECT * FROM q;
PostgreSQL 输出
是否可以在 postgreSQL 中保持与 oracle 中生成的显示顺序相同的显示顺序?