让我说我创建这样的类型:
CREATE TYPE books AS (
book_id NUMERIC
, row_num NUMERIC
);
我想编写一个查询,向我返回书籍的属性(book_id,row_num)。
我不确定该怎么做?
答案 0 :(得分:1)
使用此
SELECT array_agg(a.attname)
FROM pg_class c JOIN pg_attribute a
ON c.oid = a.attrelid
WHERE c.relname = 'books';
结果
array_agg
-------------------
{book_id,row_num}
(1 row)