PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

Qual é a diferença entre `->>` e `->` no Postgres SQL?


-> retorna json(b) e ->> retorna 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