Skip to main content
1 of 5
adopilot
  • 2.4k
  • 8
  • 31
  • 46

Find tables whit two different index on sam column in Postgresql database

I having issue whit scaffolding PostgreSQL db because npgsql does not handles well tables with two index on same column.

I am trying to find these index / tables so I can exude them from my scaffolding command.

I am trying to find tables similar to this.

CREATE TABLE public.altreproc
(
  apcod integer NOT NULL,
  aptip character(3),
  apcam character(3),
  CONSTRAINT altreproc_pkey PRIMARY KEY (apcod)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE public.altreproc
  OWNER TO postgres;

CREATE INDEX ialtreproc1
  ON public.altreproc
  USING btree
  (aptip COLLATE pg_catalog."default");

CREATE INDEX ialtreproc2
  ON public.altreproc
  USING btree
  (apcam COLLATE pg_catalog."default");

CREATE INDEX ialtreproc3
  ON public.altreproc
  USING btree
  (aptip COLLATE pg_catalog."default" DESC);

My problem is when a table has 2 different index with the same column (one ASC and one DESC); I am trying to query tables / indexes like this in db which I am trying to scaffold.

adopilot
  • 2.4k
  • 8
  • 31
  • 46