我在 PostgreSQL 中有一个包含一些数据的表:
create table t2 (
key jsonb,
value jsonb
);
INSERT INTO t2(key, value)
VALUES
('1', '"test 1"')
,('2', '"test 2"')
,('3', '"test 3"')
,('[]', '"test 4"')
,('[1]', '"test 5"')
,('[2]', '"test 6"')
,('[3]', '"test 7"')
,('[1, 2]', '"test 8"')
,('[1, 2, 3]', '"test 9"')
,('[1, 3]', '"test 10"')
,('[1,2,4]', '"test 11"')
,('[1, 2,4]', '"test 12"')
,('[1,3,13]', '"test 13"')
,('[1, 2, 15]', '"test 15"');
Run Code Online (Sandbox Code Playgroud)
我尝试像这样对这些行进行排序:
SELECT key FROM t2 order by key;
Run Code Online (Sandbox Code Playgroud)
结果是:
[]
1
2
3
[1] …
Run Code Online (Sandbox Code Playgroud)