相关疑难解决方法(0)

从sql query postgres 9.4创建嵌套的json

我需要从查询完全结构化的JSON得到结果.我可以在postgres中看到,有些内置函数可能很有用.

作为一个例子,我创建了如下结构:

    -- Table: person

-- DROP TABLE person;

CREATE TABLE person
(
  id integer NOT NULL,
  name character varying(30),
  CONSTRAINT person_pk PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE person
  OWNER TO postgres;

  -- Table: car

-- DROP TABLE car;

CREATE TABLE car
(
  id integer NOT NULL,
  type character varying(30),
  personid integer,
  CONSTRAINT car_pk PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE car
  OWNER TO postgres;

  -- Table: wheel

-- DROP TABLE wheel;

CREATE …
Run Code Online (Sandbox Code Playgroud)

sql postgresql json aggregate-functions postgresql-9.4

6
推荐指数
2
解决办法
5754
查看次数