【发布时间】:2020-06-12 04:46:13
【问题描述】:
我正在运行 Postgres 12 我有一个审计字段复合类型,用于防止我的表太胖。
create type adt_flds as
(
created_at timestamp,
updated_at timestamp,
created_by text,
updated_by text,
created_by_client_addr inet,
updated_by_client_addr inet,
created_by_client_cmptr text,
updated_by_client_cmptr text
);
create table if not exists excel.equip_type
(
equip_type_id serial not null constraint equip_type_pk primary key,
descrip text,
adt_flds adt_flds
);
--Creates a syntax error
create index equip_type_adt_flds_index
on excel.equip_type (adt_flds.created_at);
我想要索引 created_at 字段,所以当我在 WHERE 语句中过滤 created_at 时,我的查询可以索引扫描而不是堆扫描。我的问题是我的 create index 语句出现语法错误。我将如何修复我的语法,以便我可以在我的 adt_flds 类型的只有 1 个元素上建立索引?
[42601] 错误:“)”位置或附近的语法错误:85
【问题讨论】:
-
您的意思是equip_type 而不是equip_usage?你能告诉我们你的语法错误吗?
-
我确实做到了。谢谢。我更正了问题
标签: postgresql