postgresql 字符串变json 再还原
SELECT to_json('some "text"'::text)
select array[to_json('Some "text"'::TEXT)] ;
select array_to_json(array[to_json('Some "text"'::TEXT)]) ;
select array_to_json(array[to_json('Some "text"'::TEXT)])->>0 ;
select length( array_to_json(array[to_json('Some "text"'::TEXT)])->>0 );
-- 神奇的postgresql json 转表 与表转josn 表中列的神奇操作
select * from json_to_record('{"a":1,"b":[1,2,3],"c":"bar"}') as x(a int, b INTEGER[], c text) SELECT row_to_json( a.* ) from (select * from json_to_record('{"a":1,"b":[1,2,3],"c":"bar"}') as x(a int, b INTEGER[], c text)) a
-- 今天是第几周 SELECT EXTRACT(WEEK FROM now()); -- 第几个月 SELECT EXTRACT(MONTH FROM now()); -- 第几个季度 SELECT EXTRACT(quarter FROM now()); -- 第几年 SELECT EXTRACT(year FROM now());