ORA-02449

Error: ORA-02449: unique/primary keys in table referenced by foreign keys

Causa: An attempt was made to drop a table with unique or primary keys referenced by foreign keys in another table.

Acción: Before performing the above operations the table, drop the foreign key constraints in other tables. You can see what constraints are referencing a table by issuing the following command:

COMENTARIOS:

por daniel | 07/11/2008 17:25:26

RE: ORA-02449

DROP TABLE profesor;
DROP TABLE persona;
DROP TABLE facultad;
DROP TABLE valor_matricula;
DROP TABLE tipo_obligacion;
DROP TABLE carrera;
DROP TABLE materia;
DROP TABLE pensum;
DROP TABLE estudiante;
DROP TABLE obligaciones_eco;
DROP TABLE matricula;
CREATE TABLE profesor (
cod_profesor VARCHAR(10) NOT NULL,
nombre VARCHAR(10) NOT NULL,
CONSTRAINT profesor_pk PRIMARY KEY(cod_profesor)
);
CREATE TABLE persona (
ident NUMBER(10) NOT NULL,
nombre VARCHAR(20) NOT NULL,
apellido VARCHAR(20) NOT NULL,
direccion VARCHAR(20) NOT NULL,
telefono VARCHAR(20) NOT NULL,
CONSTRAINT persona_pk PRIMARY KEY(ident)
);
CREATE TABLE facultad (
cod_facultad VARCHAR(10) NOT NULL,
nombre_facultad VARCHAR(20) NOT NULL,
desc_facultad NUMBER(20) NOT NULL,
CONSTRAINT facultad_pk PRIMARY KEY(cod_facultad)
);
CREATE TABLE valor_matricula (
semestre NUMBER(5) NOT NULL,
valor_matricula NUMBER(20) NOT NULL,
CONSTRAINT valor_matricula_pk PRIMARY KEY(semestre)
);
CREATE TABLE tipo_obligacion (
cod_obligacion VARCHAR(10) NOT NULL,
valor_obligacion NUMBER(20) NOT NULL,
desc_obligacion NUMBER(20) NOT NULL,
CONSTRAINT tipo_obligacion_pk PRIMARY KEY(cod_obligacion)
);
CREATE TABLE carrera (
cod_carrera VARCHAR(10) NOT NULL,
cod_facultad VARCHAR(10) NOT NULL,
CONSTRAINT carrera_pk PRIMARY KEY(cod_carrera),
CONSTRAINT facultad_fk FOREIGN KEY(cod_facultad)
REFERENCES facultad(cod_facultad)
);
CREATE TABLE materia (
cod_materia VARCHAR(10) NOT NULL,
cod_profesor VARCHAR(10) NOT NULL,
creditos NUMBER(5) NOT NULL,
nombre_materia VARCHAR(20) NOT NULL,
desc_materia NUMBER(10) NOT NULL,
horario VARCHAR(20) NOT NULL,
CONSTRAINT materia_pk PRIMARY KEY(cod_materia),
CONSTRAINT profesor_fk FOREIGN KEY(cod_profesor)
REFERENCES profesor(cod_profesor)
);
CREATE TABLE pensum (
cod_materia VARCHAR(10) NOT NULL,
cod_carrera VARCHAR(10) NOT NULL,
CONSTRAINT pensum_pk PRIMARY KEY(cod_materia),
CONSTRAINT carrera_fk FOREIGN KEY(cod_carrera)
REFERENCES carrera(cod_carrera)
);
CREATE TABLE estudiante (
carnet NUMBER(10) NOT NULL,
cod_carrera VARCHAR(10) NOT NULL,
id_estudiante NUMBER(10) NOT NULL,
promedio_anterior REAL NOT NULL,
CONSTRAINT estudiante_pk PRIMARY KEY(carnet),
CONSTRAINT carrera_fk2 FOREIGN KEY(cod_carrera)
REFERENCES carrera(cod_carrera)
);
CREATE TABLE obligaciones_eco (
cod_obligaciones VARCHAR(10) NOT NULL,
carnet NUMBER(10) NOT NULL,
CONSTRAINT obligaciones_eco_pk PRIMARY KEY(cod_obligaciones),
CONSTRAINT estudiante_fk FOREIGN KEY(carnet)
REFERENCES estudiante(carnet)
);

CREATE TABLE matricula (
semestre NUMBER(5) NOT NULL,
carnet NUMBER(10) NOT NULL,
nro_matricula NUMBER(10) NOT NULL,
CONSTRAINT matricula_pk PRIMARY KEY(semestre),
CONSTRAINT estudiante_fk2 FOREIGN KEY(carnet)
REFERENCES estudiante(carnet)
);
INSERT INTO profesor VALUES (
1, 'gustavo');
INSERT INTO profesor VALUES (
2, 'angelica');
INSERT INTO profesor VALUES (
3, 'gabriel');
INSERT INTO profesor VALUES (
4, 'andres');
INSERT INTO profesor VALUES (
5, 'gladys');
INSERT INTO profesor VALUES (
6, 'jhonny');
INSERT INTO profesor VALUES (
7, 'chucho');
INSERT INTO profesor VALUES (
8, 'leon');
INSERT INTO profesor VALUES (
9, 'roberto');
INSERT INTO profesor VALUES (
10, 'mario');
INSERT INTO persona VALUES (
2008117038, 'camilo', 'rodriguez','clle-38-sur','3456789');
INSERT INTO persona VALUES (
2006117026, 'lucas', 'garcia','clle-28-sur','4567890');
INSERT INTO persona VALUES (
2008112439, 'juan', 'uribe','clle-18-norte','5555555');
INSERT INTO persona VALUES (
2003119034, 'andres', 'uribe','clle-38-norte','2341567');
INSERT INTO persona VALUES (
2008113445, 'mateo', 'castaño','tv-18-norte','6666666');
INSERT INTO persona VALUES (
2005567889, 'homero', 'simpson','clle-6-norte','6712345');
INSERT INTO persona VALUES (
2008117036, 'juliana', 'vasquez','tv-66-este','6789011');
INSERT INTO persona VALUES (
2002456789, 'juan', 'molina','av 34d-sur','4532323');
INSERT INTO persona VALUES (
2006889045, 'roberto', 'paniagua','clle 21 b','78923232');
INSERT INTO persona VALUES (
2008345678, 'manuel', 'gonzalez','av-6-norte','1111111');
INSERT INTO facultad VALUES (
1,'ingenierias', 250000);
INSERT INTO facultad VALUES (
2, 'c_empresariales', 150000);
INSERT INTO facultad VALUES (
3, 'derecho', 150000);
INSERT INTO facultad VALUES (
4, 'c_humanas', 150000);
INSERT INTO facultad VALUES (
5, 'idiomas', 150000);
INSERT INTO facultad VALUES (
6, 'medicina', 150000);
INSERT INTO facultad VALUES (
7, 'c_basicas', 150000);
INSERT INTO valor_matricula VALUES (
1, 1150000);
INSERT INTO valor_matricula VALUES (
2, 1150000);
INSERT INTO valor_matricula VALUES (
3, 1150000);
INSERT INTO valor_matricula VALUES (
4, 1150000);
INSERT INTO valor_matricula VALUES (
5, 1150000);
INSERT INTO valor_matricula VALUES (
6, 1150000);
INSERT INTO valor_matricula VALUES (
7, 1150000);
INSERT INTO valor_matricula VALUES (
8, 1150000);
INSERT INTO valor_matricula VALUES (
9, 1150000);
INSERT INTO valor_matricula VALUES (
10, 1150000);
INSERT INTO tipo_obligacion VALUES (
1, 1150000,150000);
INSERT INTO tipo_obligacion VALUES (
2, 700000,150000);
INSERT INTO tipo_obligacion VALUES (
3, 1150000,250000);
INSERT INTO tipo_obligacion VALUES (
4, 700000,150000);
INSERT INTO tipo_obligacion VALUES (
5, 1150000, 250000);
INSERT INTO tipo_obligacion VALUES (
6, 700000,150000);
INSERT INTO tipo_obligacion VALUES (
7, 1150000,250000);
INSERT INTO tipo_obligacion VALUES (
8, 700000,150000);
INSERT INTO tipo_obligacion VALUES (
9, 1150000,250000);
INSERT INTO tipo_obligacion VALUES (
10, 700000,150000);
INSERT INTO carrera VALUES (
111, '1');
INSERT INTO carrera VALUES (
112, '3');
INSERT INTO carrera VALUES (
113, '4');
INSERT INTO carrera VALUES (
114, '6');
INSERT INTO carrera VALUES (
115, '7');
INSERT INTO materia VALUES (
17000, '1', '3','calculo',150000,'L-M-W-6:am');
INSERT INTO materia VALUES (
17001, '2', '3', 'calculoII','150000','J-V-10:00am');
INSERT INTO materia VALUES (
17002, '3', '3', 'calculoIII','150000','L-M-12:00am');
INSERT INTO materia VALUES (
17003, '4', '3', 'calculoIV', '150000','L-M-2:00pm');
INSERT INTO materia VALUES (
17004, '5', '3', 'economia', '150000','L-M-2:00pm');
INSERT INTO materia VALUES (
17005, '6', '3', 'algoritmos', '150000','M-J-2:00pm');
INSERT INTO materia VALUES (
17006, '7', '3', 'lenguajes', '150000','W-J-2:00pm');
INSERT INTO materia VALUES (
17007, '8', '3', 'programacion', '150000','M-J-2:00pm');
INSERT INTO materia VALUES (
17008, '9', '3', 'bases', '150000','L-M-2:00pm');
INSERT INTO materia VALUES (
17009, '10', '3', 'compiladores', '150000','L-M-2:00pm');
INSERT INTO pensum VALUES (
17000, '111');
INSERT INTO pensum VALUES (
17001, '111');
INSERT INTO pensum VALUES (
17002, '111');
INSERT INTO pensum VALUES (
17003, '111');
INSERT INTO pensum VALUES (
17004, '111');
INSERT INTO pensum VALUES (
17005, '111');
INSERT INTO pensum VALUES (
17006, '111');
INSERT INTO pensum VALUES (
17007, '111');
INSERT INTO pensum VALUES (
17008, '111');
INSERT INTO pensum VALUES (
17009, '111');
INSERT INTO estudiante VALUES (
2008117038, '111', '8357442',4.8);
INSERT INTO estudiante VALUES (
2006117026, '111', '899456', 4.4);
INSERT INTO estudiante VALUES (
2008112439, '111', '8799456', 3.1);
INSERT INTO estudiante VALUES (
2003119034, '111', '8678234',2.5);
INSERT INTO estudiante VALUES (
2008113445, '111', '8456123',4.1);
INSERT INTO estudiante VALUES (
2005567889, '111', '8990234',3.4);
INSERT INTO estudiante VALUES (
2008117036, '111', '7456121',3.1);
INSERT INTO estudiante VALUES (
2002456789, '111', '6990456',2.8);
INSERT INTO estudiante VALUES (
2006889045, '111', '8344523',5.0);
INSERT INTO estudiante VALUES (
2008345678, '111', '876555',2.1);
INSERT INTO obligaciones_eco VALUES (
1, 2008117038);
INSERT INTO obligaciones_eco VALUES (
2, 2006117026);
INSERT INTO obligaciones_eco VALUES (
3, 2008112439);
INSERT INTO obligaciones_eco VALUES (
4, 2003119034);
INSERT INTO obligaciones_eco VALUES (
5, 2008113445);
INSERT INTO obligaciones_eco VALUES (
6, 2005567889);
INSERT INTO obligaciones_eco VALUES (
7, 2008117036);
INSERT INTO obligaciones_eco VALUES (
8, 2002456789);
INSERT INTO obligaciones_eco VALUES (
9, 2006889045);
INSERT INTO obligaciones_eco VALUES (
10, 2008345678);
INSERT INTO matricula VALUES (
1, 2008117038, 001);
INSERT INTO matricula VALUES (
2, 2006117026, 002);
INSERT INTO matricula VALUES (
3, 2008112439, 003);
INSERT INTO matricula VALUES (
4, 2003119034, 004);
INSERT INTO matricula VALUES (
5, 2008113445, 005);
INSERT INTO matricula VALUES (
6, 2005567889, 006);
INSERT INTO matricula VALUES (
7,2008117036, 007);
INSERT INTO matricula VALUES (
8, 2002456789,008);
INSERT INTO matricula VALUES (
9, 2006889045, 009);
INSERT INTO matricula VALUES (
10, 2008345678,010);

por Before performing the above operations the table, drop the foreign key constraints in other tables. You can see what constraints are referencing a table by issuing the following command: | 19/03/2020 02:29:26

RE: ORA-02449

Before performing the above operations the table, drop the foreign key constraints in other tables. You can see what constraints are referencing a table by issuing the following command:

por Before performing the above operations the table, drop the foreign key constraints in other tables. You can see what constraints are referencing a table by issuing the following command: | 19/03/2020 02:29:55

RE: ORA-02449

Msg 1770, Level 16, State 0, Line 1
Foreign key \'fk_fc1\' references invalid column \'clave_c\' in referenced table \'carrera\'.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.