From: | "Rosa Vargas Urbina" <rvargas(at)correo(dot)cnart(dot)mx> |
---|---|
To: | <pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx> |
Subject: | [Pgsql-ayuda] Respondiendo a Okeona;-p: |
Date: | 2004-01-30 01:01:43 |
Message-ID: | OCEOJHHMBADGGCGACNPPOEOICHAA.rvargas@correo.cnart.mx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Respondiendo a Okeona;-p:
<Hola a todos!
<Tengo problemas para crear FOREIGN KEY, me da un error y no se a que se
<refiere. Podría ser que no la creara bien. La cree:
<CREATE TABLE table_name(
<...
<CONSTRAINT constraint_name FOREIGN KEY(campo1,campo2) REFERENCES
<ref_table(ref_campo1,ref_campo2));
<*campo1 y campo2 son las únicas claves primarias de esta tabla.
<*ref_campo1 y ref_campo2 son claves primarias de ref_table, pero hay otra
<más en está tabla(ref_table)
<El error:
<ERROR: UNIQUE constraint matching give keys for referenced table
"ref_table"
not found.
Pues bien yo lo hago de la siguiente manera, por ejemplo :
CREATE TABLE modalidad (
id int NOT NULL ,
nombre varchar (30) NOT NULL,
abrev char (3) NOT NULL,
descripcion text NULL,
PRIMARY KEY (id)
);
CREATE TABLE aspirante (
id serial,
ap_paterno varchar(40) NOT NULL,
ap_materno varchar(40) NOT NULL,
nombre1 varchar(30) NOT NULL,
PRIMARY KEY (id)
);
El siguinete texto tiene dos llaves foraneas de las
tablas:aspirante,modalidad, domicilio.
CREATE TABLE datosb_aspirante (
id serial ,
aspirante_id int4 NOT NULL REFERENCES
aspirante(id),
modalidad_id int NOT NULL REFERENCES
modalidad(id),
PRIMARY KEY (id)
);
PD: Como los id's son de tipo serial entonces se deben generar permisos
sobre estos campos
GRANT ALL ON aspirante_id_seq TO apache;
GRANT ALL ON domicilio_aspirante_id_seq TO apache;
GRANT ALL ON datosb_aspirante_id_seq TO apache;
Ojala te haya podido ayudar!
Saludos
Rosa Vargas
From | Date | Subject | |
---|---|---|---|
Next Message | interlinux interlinux | 2004-01-30 02:46:22 | [Pgsql-ayuda] update |
Previous Message | Marcos Garrido | 2004-01-29 22:57:36 | [Pgsql-ayuda] PostgreSQL: problemas con pg_connect |