SQL中->>
和->
的区别是什么?
在这个线程(Check if field exists in json type column postgresql)中,回答者基本上建议使用,
json->'attribute' is not null
而不是
json->>'attribute' is not null
为什么使用单箭头而不是双箭头?根据我有限的经验,两者都做同样的事情.
SQL中->>
和->
的区别是什么?
在这个线程(Check if field exists in json type column postgresql)中,回答者基本上建议使用,
json->'attribute' is not null
而不是
json->>'attribute' is not null
为什么使用单箭头而不是双箭头?根据我有限的经验,两者都做同样的事情.
->
返回json(b),->>
返回text
:
with t (jo, ja) as (values
('{"a":"b"}'::jsonb,('[1,2]')::jsonb)
)
select
pg_typeof(jo -> 'a'), pg_typeof(jo ->> 'a'),
pg_typeof(ja -> 1), pg_typeof(ja ->> 1)
from t
;
pg_typeof | pg_typeof | pg_typeof | pg_typeof
-----------+-----------+-----------+-----------
jsonb | text | jsonb | text