ORA-02270

Error: ORA-02270: no matching unique or primary key for this column-list

Causa: An attempt was made to reference a unique or primary key in a table with a CREATE or ALTER TABLE statement when no such key exists in the referenced table.

Acción: Add the unique or primary key to the table or find the correct names of the columns with the primary or unique key, and try again.

COMENTARIOS:

por DaEnVa | 17/08/2009 15:27:20

RE: ORA-02270

Tambien te puede dar este error porque quieres relacionar dos tablas en forma inversa, o sea lo normal es maestro (Encabezado) -> Detalle, y tu lo quieres hacer del Detalle al Encabezado, queriendo decir que el detalle es el encabezado y eso no puede ser.

por df | 05/10/2010 11:00:56

RE: ORA-02270

ORA-02270: no hay ninguna clave única o primaria correspondiente para esta lista de columnas

por chechomancr | 10/04/2011 01:46:09

RE: ORA-02270

Hola, no eh podido solucionarlo:

tengo los siguientes datos:


CREATE TABLE UTN_CENTRO_SALUD(
COD_CENTRO_SALUD NUMBER (6,0) NOT NULL ,
DSC_CENTRO_SALUD VARCHAR2(25) NOT NULL,
ACTIVO NUMBER(1,0) DEFAULT 1 CHECK (ACTIVO IN (0,1)) );



ALTER TABLE UTN_CENTRO_SALUD ADD CONSTRAINT CENTRO_SALUD_PK PRIMARY KEY(COD_CENTRO_SALUD, DSC_CENTRO_SALUD);










CREATE TABLE UTN_ESPECIALIDAD_CS(
COD_ESPECIALIDAD_CS NUMBER(8,0) NOT NULL , /* CONSECUTIVO: 1,2,3... LA TAREA ES QUE NO SE REPITA. */
COD_CENTRO_SALUD NUMBER (6,0) UNIQUE NOT NULL , /* CENTRO DE SALUD */
COD_ESPECIALIDAD NUMBER(3,0) NOT NULL ,
COD_SERVICIO NUMBER(2,0) NOT NULL ,
TIP_SERVICIO NUMBER(1,0) NOT NULL ,
TIP_SEXO CHAR(1) NOT NULL ,
TIP_IMPRESION_HORA NUMBER(3,0) NOT NULL , /* DOS TIPOS HORA EXACTA /0/ Y HARA EN PUNTO /1/ */
ACTIVO NUMBER(1,0) DEFAULT 1 CHECK (ACTIVO IN (0,1)) );



ALTER TABLE UTN_ESPECIALIDAD_CS ADD CONSTRAINT ESPECIALIDAD_CS_PK PRIMARY KEY (COD_ESPECIALIDAD_CS);

ALTER TABLE UTN_ESPECIALIDAD_CS ADD CONSTRAINT ESP_CS_A_FK FOREIGN KEY(COD_CENTRO_SALUD)
REFERENCES UTN_CENTRO_SALUD(COD_CENTRO_SALUD);

ALTER TABLE UTN_ESPECIALIDAD_CS ADD CONSTRAINT ESP_CS_B_FK FOREIGN KEY(COD_ESPECIALIDAD, COD_SERVICIO, TIP_SERVICIO)
REFERENCES UTN_ESPECIALIDAD(COD_ESPECIALIDAD,COD_SERVICIO, TIP_SERVICIO);





el error ocurre al hacer el FK:

ALTER TABLE UTN_ESPECIALIDAD_CS ADD CONSTRAINT ESP_CS_A_FK FOREIGN KEY(COD_CENTRO_SALUD)
REFERENCES UTN_CENTRO_SALUD(COD_CENTRO_SALUD);



y no eh podido solucionarlo


por David Sánchez | 11/04/2011 08:43:01

RE: ORA-02270

Hola chechomancr .

Una foreign key necesita ser apuntada a una primary key de otra tabla. En tu caso, apunta a UTN_CENTRO_SALUD.COD_CENTRO_SALUD . Pero si miras la primary key de esta tabla verás que es una primary key compuesta (COD_CENTRO_SALUD, DSC_CENTRO_SALUD).

Las dos posibles soluciones son o bien que en la primera tabla la primary key sea sólo COD_CENTRO_SALUD o bien en la tabla UTN_ESPECIALIDAD_CS , incluir también el campo DSC_CENTRO_SALUD y hacer una foreign que incluya los dos campos hacia la primera tabla.

Espero haberte ayudado.

por rafael carrillo roque | 24/01/2013 22:41:11

RE: ORA-02270

bueno amigos no se mucho pero me a pasado estoy seguro que a la tabla q estas haciendo referencia tiene dos campos como prikary key eso kiere decir que cuando agas referencia tienes q hacerlo para los dos si lo lo referencias auno solo te va a generar este error bno espero aver ayudado en algo

por Marcel De La Barra Olate | 29/06/2013 06:55:00

RE: ORA-02270

tengo estas dos tablas y me sale el error ora-02270 ayuda porfavor
create table turbina_gas(
cod_tg number,
constraint pk1 primary key (cod_tg,velocidad_giro_tg),
presion_comprecion number not null,
tem_camara_combustion varchar2 (10) not null,
velocidad_giro_tg number not null)

create table generador_electrico_tg(
cod_getg number primary key,
velocidad_giro_tg number not null,
voltage_generado_tg number not null,
CONSTRAINT fk6 foreign key (velocidad_giro_tg) REFERENCES turbina_gas(velocidad_giro_tg))

por Jimenez C. Edwin | 13/06/2017 01:47:52

RE: ORA-02270

Hola, el error se puede estar generando debido a que tienes claves compuestas Tabla padre(PK,FK) y al heredar la PK a tabla hija solo se esta dando a conocer una sola clave cuando tiene que ser la clave compuesta:

Construcción de clave compuesta (PK + FK):

CONSTRAINT PK_TABLA_PADRE PRIMARY KEY(PKTABLA_PADRE, FKTABLA_PADRE)

Clave heredada en tabla hija de forma compuesta:

CONSTRAINT FK_TABLA_HIJA FOREIGN KEY(FK1TABLA_HIJA, FK2TABLA_HIJA) REFERENCES TABLA_PADRE(PKTABLA_PADRE, FKTABLA_PADRE));

Salu2!

por Nacho | 09/01/2021 20:37:28

RE: ORA-02270

yo tambien tengo ese mismo problema y no se como resolverlo si alguein me pude ayudar se lo agradeceria
esta es la tabla que estoy creando
create table inventario(
Clave_articulo number(5),
Cantidad_articulo number(3),
Cantidad_entrada number(3) constraint CantidadEntrada_nn not null,
Cantidad_salida number(3) constraint CantidadSalida_nn not null,
Fecha_surtido timestamp constraint FechaSurtido_nn not null,
Fecha_salida timestamp constraint FechaSalida_nn not null,
primary key(Clave_articulo),
foreign key(Clave_articulo) references articulos(Clave_articulo),
foreign key(Cantidad_articulo) references articulos(Cantidad_articulo));

y se supone que a la tabla que hago referencia a la primary key es esta y ya esta creada

create table articulos(
Clave_articulo number(5) constraint ClaveArticulo_pk primary key,
Tipo_articulo varchar2(10) constraint TipoArticulo_ck check(Tipo_articulo in(\'Libro\',\'Producto\')),
Cantidad_articulo number(3) constraint CantidadArticulo_nn not null,
Precio_articulo decimal);