Re: listar llaves foraneas y primarias

From: "Gilberto Castillo" <gilberto(dot)castillo(at)etecsa(dot)cu>
To: "MARIA ANTONIETA RAMIREZ SOLIS" <maramirez(at)ulsaneza(dot)edu(dot)mx>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: listar llaves foraneas y primarias
Date: 2015-05-08 15:00:30
Message-ID: 58187.192.168.207.54.1431097230.squirrel@webmail.etecsa.cu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

> Buena tarde
>
> Disculpen, necesito un query que me de la tabla, sus campos tipos de datos
> de sus campos, llaves primarias y foraneas y a que tabla hacen esta
> relacion , tienen algun query que me pueda dar esta informacion??
>
> Se los agradeceria bastante

Quizás no es lo que necesitas, pero lo puedes acomodar: te devuelves los
tablas y sus ídices.

SELECT
nspname,relname,
round(100 * pg_relation_size(indexrelid) / pg_relation_size(indrelid)) / 100
AS index_ratio,
pg_size_pretty(pg_relation_size(indexrelid)) AS index_size,
pg_size_pretty(pg_relation_size(indrelid)) AS table_size
FROM pg_index I
LEFT JOIN pg_class C ON (C.oid = I.indexrelid)
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE
nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND
C.relkind='i' AND
pg_relation_size(indrelid) > 0;

Saludos,
Gilberto Castillo
ETECSA, La Habana, Cuba

Attachment Content-Type Size
unknown_filename text/plain 179 bytes
unknown_filename text/plain 157 bytes

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Gerardo Herzig 2015-05-09 17:46:00 Re: Ayuda para optimizar consulta
Previous Message Freddy Martinez Garcia 2015-05-08 14:21:38 Re: columna concatenada