El día 27 de marzo de 2009 12:01, Alvaro Herrera <alvhe...@alvh.no-ip.org> escribió: > Emanuel Calvo Franco escribió: > >> Alvaro: Se que tiene que haber pero no logro 'joinar' correctamente >> las tablas del catalogo... >> ¿cual es la consulta que trae el nombre del campo que es primary key y su >> tipo? Estuve explorando lo que utiliza psql en sus consultas pero no >> no doy en el clavo, >> que campo linkea pg_constraint y pg_attiributes? > > Necesitas pg_index, no pg_constraint. Prueba así: > > select > pg_attribute.attname, > format_type(pg_attribute.atttypid, pg_attribute.atttypmod) > from pg_index, pg_class, pg_attribute > where > pg_class.oid = 'foo'::regclass and > indrelid = pg_class.oid and > pg_attribute.attrelid = pg_class.oid and > pg_attribute.attnum = any(pg_index.indkey); > > > alvherre=# create table emanuel (calvo int, franco numeric(3, 2), primary key > (calvo, franco)); > NOTICE: CREATE TABLE / PRIMARY KEY creará el índice implícito «emanuel_pkey» > para la tabla «emanuel» > CREATE TABLE > > alvherre=# select > alvherre-# pg_attribute.attname, > alvherre-# format_type(pg_attribute.atttypid, pg_attribute.atttypmod) > alvherre-# from pg_index, pg_class, pg_attribute > alvherre-# where > alvherre-# pg_class.oid = 'public.emanuel'::regclass and > alvherre-# indrelid = pg_class.oid and > alvherre-# pg_attribute.attrelid = pg_class.oid and > alvherre-# pg_attribute.attnum = any(pg_index.indkey); > > attname | format_type > ---------+-------------- > calvo | integer > franco | numeric(3,2) > (2 filas) > > -- > Alvaro Herrera http://www.amazon.com/gp/registry/5ZYLFMCVHXC > "I must say, I am absolutely impressed with what pgsql's implementation of > VALUES allows me to do. It's kind of ridiculous how much "work" goes away in > my code. Too bad I can't do this at work (Oracle 8/9)." (Tom Allison) > http://archives.postgresql.org/pgsql-general/2007-06/msg00016.php >
Grosso! :D El problema que estaba pensando es que no soportaría llaves compuestas... a menos que el último parámetro fuera un string muy poco elegante como (para este caso ): '3 3.4' . Pero podría verlo esto... -- Emanuel Calvo Franco Sumate al ARPUG ! (www.postgres-arg.org - www.arpug.com.ar) ArPUG / AOSUG Member Postgresql Support & Admin -- TIP 4: No hagas 'kill -9' a postmaster