If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Today i registered to ask a strange situacion that happened to me with a very simple querys., so i want to build the same schema of a litlle database like in the map image, i create manually the all tables and all columns with data (see the attach New DB), but right now is imposible to me to add the primaray keys like in atached image!!
for example
CONSTRAINT PEDIDOS_FOREIGN_KEY FOREIGN KEY (ID_CLIENTE) REFERENCES CLIENTES(ID_CLIENTE),
CONSTRAINT PEDIDOS_FOREIGN_KEY FOREIGN KEY (ID_EMPLEADO) REFERENCES EMPLEADOS(ID_EMPLEADO))
and is not working., he give me the error
ORA-02264: name already used by an existing constraint
but where!! i make a drop to all tables 10 times today trying to make the conexion with PK and FK and he steel give me the same error!!
is a bug., or what?? because i make everything ok.
You are creating two constraints with the same name.
You have to use two different names if you create two constraints.
False ., because if you see the attach image ID_CLIENTE is from Clientes table and ID_EMPLEADO is from Empleados table.
the only word that i repeat is PEDIDOS but this is the table where i need to define the 2 constraints (id_cliente and id_empleado).,and the constraint query is correct!
False ., because if you see the attach image ID_CLIENTE is from Clientes table and ID_EMPLEADO is from Empleados table.
The IDs might be from different tables but you are supplying the same name for both constraints (that's why the error message says: "name already used by an existing constraint")
Quote:
the only word that i repeat is PEDIDOS but this is the table where i need to define the 2 constraints (id_cliente and id_empleado).,and the constraint query is correct!
No you repeat the name of the constraint (PEDIDOS_FOREIGN_KEY)
In the attached file there are no constraint definitions whatsoever and the two lines you have shown us in your initial post repeat the same name for two different constraints.
False ., because if you see the attach image ID_CLIENTE is from Clientes table and ID_EMPLEADO is from Empleados table.
the only word that i repeat is PEDIDOS but this is the table where i need to define the 2 constraints (id_cliente and id_empleado).,and the constraint query is correct!
False. The constraint name has to be different, but you are talking about referenced master table and columns in both child/master tables. Oracle seems to be the same opinion as shammat too.
Here is one more thread about the same error: Trouble assigning foreign key
Once again: problem is in duplicate constraint name (put into bold by shammat).
If you still do not believe it, please start reading this post from the beginning.
Well., I steel confuze, because in this thread http://www.dbforums.com/oracle/1672722-ora-02264-a.html one expert guy (i think that is a guru for the number of messages) give the next resolution
Maybe, if you read it carefully, you would find out, that the is not resolution, but another pointing to the duplicate constraint name (the same error you have in your code).
Well, you may take it from different angle.
Just imagine that you want to create two tables with the same name PEDIDOS. Does it make sense? How would you distinguish them if you wanted INSERT/DELETE/UPDATE rows from only one of them, or even, drop only one of them?
If you think that it is nonsense, just apply the same logic to constraints:
Just imagine that you want to create two constraints with the same name PEDIDOS_FOREIGN_KEY. Does it make sense? How would you distinguish them if you wanted disable, or even, drop only one of them?
However, it would fail again because COMPANIAS_DE_ENVIOS table doesn't contain primary nor unique key on NOMBRE_COMPANIA column, so you should first create one, such as
Code:
alter table companias_de_envios add constraint uk_cde unique (nombre_compania);
Of course, you need to make sure whether it makes sense or not.
Nice observation., but why in some cases is work like FOREIGN_KEY (with underscore) and in other cases like you told me (and is work!) is FOREIGN KEY (without underscore)!?
Nice observation., but why in some cases is work like FOREIGN_KEY (with underscore) and in other cases like you told me (and is work!) is FOREIGN KEY (without underscore)!?
Can you show those "some cases"? It never worked and never will with FOREIGN_KEY after its name (not as a part of the foreign key name) before column list. Only FOREIGN KEY (with space) is valid there.
For correct syntax, please, consult SQL Language Reference book for your Oracle version. It is available with other Oracle documentation books e.g. online on http://tahiti.oracle.com/