Dab tsi yog qhov txawv ntawm JSON thiab Jsonb hauv PostgreSQL?
Dab tsi yog qhov txawv ntawm JSON thiab Jsonb hauv PostgreSQL?

Video: Dab tsi yog qhov txawv ntawm JSON thiab Jsonb hauv PostgreSQL?

Video: Dab tsi yog qhov txawv ntawm JSON thiab Jsonb hauv PostgreSQL?
Video: Python! Reading and Writing JSON Files 2024, Hlis ntuj nqeg
Anonim

Cov ntaub ntawv hom json thiab jsonb , raws li txhais los ntawm lub PostgreSQL cov ntaub ntawv, yuav luag zoo tib yam; tus yuam sij txawv yog tias json cov ntaub ntawv yog khaws cia raws li ib daim qauv ntawm cov JSON input ntawv, hos jsonb khaws cov ntaub ntawv hauv a decomposed binary daim ntawv; uas yog, tsis yog ASCII / UTF-8 hlua, tab sis raws li binary code.

Hauv qhov no, Jsonb yog dab tsi hauv Postgres?

JSONB . Thaum kawg hauv Postgres 9.4 peb tau txais tiag thiab tsim nyog JSON nyob rau hauv daim ntawv ntawm JSONB . Lub B sawv rau qhov zoo dua. JSONB yog ib tug binary sawv cev ntawm JSON , qhov no txhais tau hais tias nws yog compressed thiab ntau npaum rau cia tshaj li ntawv xwb. Nws kuj muaj cov kav dej zoo sib xws ntawm hstore hauv qab.

Kuj Paub, JSON teb yog dab tsi? JSON , lossis JavaScript Object Notation, yog qhov tsawg kawg nkaus, nyeem tau hom ntawv rau kev teeb tsa cov ntaub ntawv. Nws yog siv feem ntau xa cov ntaub ntawv ntawm tus neeg rau zaub mov thiab lub vev xaib thov, ua lwm txoj hauv kev rau XML. Squarespace siv JSON khaws thiab teeb tsa cov ntsiab lus ntawm qhov chaw tsim nrog CMS.

Tsis tas li ntawd, kuv yuav nug ib kab JSON hauv PostgreSQL li cas?

Nrhiav JSON cov ntaub ntawv PostgreSQL muab ob tus neeg ua haujlwm hauv zos -> thiab ->> los pab koj nug JSON cov ntaub ntawv. Tus neeg teb xov tooj -> rov qab JSON khoom teb los ntawm tus yuam sij. Tus neeg teb xov tooj ->> rov qab JSON khoom teb los ntawm ntawv.

Postgres puas tuaj yeem khaws JSON?

Raws li tau hais ua ntej PostgreSQL txhawb ob hom ntaub ntawv: JSON thiab JSONB. Pib nrog, JSON hom ntaub ntawv khaws ib daim qauv ntawm cov ntawv sau thiab yog li kev ua haujlwm yuav tsum tau txheeb xyuas txhua zaus nws tsim nyog. Ntawm qhov tsis sib xws, JSONB yog khaws cia raws li ib tug decomposed binary hom thiab yog li tsis xav tau parsing.

Pom zoo: