開(kāi)心一笑
廈門(mén)現(xiàn)在室內(nèi)3度迈套,我打開(kāi)冰箱一看7度宏榕,趕緊躲進(jìn)冰箱
提出問(wèn)題
PostgreSQL的Json類(lèi)型如何使用???
解決問(wèn)題
準(zhǔn)備數(shù)據(jù)
創(chuàng)建表:
create table ay_json_test(
id varchar primary key,
name varchar,
json_value json
)
插入數(shù)據(jù):
insert into ay_json_test values('001','ay','{
"ay_name":"阿毅",
"home":{
"type":{"interval":
"5m"
},
"love":"now",
"you":"None"
},
"values":{
"event":["cpu_r","cpu_w"],
"data":["cpu_r"],
"threshold":[1,1]
},
"objects":{
"al":"beauty"
}
}');
例一:選擇數(shù)據(jù)
select id,name,json_value->>'ay_name' as ayName from ay_json_test where json_value ->>'ay_name' = '阿毅'
結(jié)果
例二:
select id,name,json_value->>'ay_name' as ayName,json_value ->> 'objects' as objects from ay_json_test
where json_value ->>'ay_name' = '阿毅'
結(jié)果:
例三:數(shù)組元素選擇
select json_value -> 'values'#>>'{data,0}' as objects from ay_json_test
where json_value ->>'ay_name' = '阿毅'
例四:更新數(shù)據(jù)
update ay_json_test set json_value = '{
"ay_name":"阿毅_change",
"home":{
"type":{"interval_change":
"5m"
},
"love":"now_change",
"you":"None_change"
},
"values":{
"event":["cpu_r_change","cpu_w_change"],
"data":["cpu_r_change"],
"array":[999,5]
},
"objects":{
"al":"beauty"
}
}'
where json_value ->> 'ay_name' = '阿毅'
結(jié)果:
例五:刪除數(shù)據(jù)
delete from ay_json_test where json_value ->> 'ay_name' = '阿毅_change'
結(jié)果,數(shù)據(jù)庫(kù)已經(jīng)沒(méi)有數(shù)據(jù)了侵佃。
讀書(shū)感悟
來(lái)自《超級(jí)讀心術(shù)》
- 當(dāng)人處于興奮狀態(tài)的時(shí)候麻昼,他的瞳孔會(huì)自然而然地放大;
而處在消極馋辈、戒備狀態(tài)時(shí)抚芦,瞳孔則會(huì)縮小。這些變化不是人的意識(shí)所能控制的迈螟,
深諳此道的人在某些場(chǎng)合總是戴著有色眼鏡叉抡,為的就是掩飾自己瞳孔的真實(shí)變化。 - 面部表情是人內(nèi)心的晴雨表答毫,而且這個(gè)晴雨表無(wú)國(guó)界褥民,在人類(lèi)當(dāng)中是通用的,
也正是因?yàn)檫@樣洗搂,人們接觸社會(huì)時(shí)最早學(xué)會(huì)的大概就是控制自己的表情了 - 看一個(gè)人怎樣消返,就看他身邊的人怎樣