0
votes

I am maintaining a legacy application and I recently got contacted that people are getting an error message when they try to fill one of our oracle tables. Now, those oracle tables are not in our care, but I still want to try out something to help find the problem.

Anyway, the error message is the following:

java.sql.SQLException: ORA-00001: unique constraint (REO0.PK_TableName) violated :

I know I can find a lot of information online through google and here about this error message. That is not what my question is about.

The question is: the tablename shown here (which I put in bold), is that the name of the table, or is the PK_ part added to represent 'primary key' ?

Reason why I ask is: I can't directly get to this database, but somehow I can see all tables in REO0 and I can find one with TableName but not one with *PK_TableName* as the name for a table. So if this PK_ would refer to something like 'primary key' (which the constraint of is violated) then it would make a bit more sense.

1

1 Answers

6
votes

PK_tablename is the name of the constraint, and as Alex Poole states in a good comment, it has been specified in the DDL (CREATE TABLE ... (columns, CONSTRAINT PK_tablename PRIMARY KEY(columns...) ), or ALTER TABLE ... ADD CONSTRAINT PK_tablename PRIMARY KEY(columns...) or CREATE UNIQUE INDEX PK_tablename ON ... (columns) for example). When no name has been given, Oracle generates a name which begins with SYS.

Note that usually PK_x suggests a primary key for table x, but your constraint might also be a foreign key constraint or a not null constraint for example.

The following query will tell you all:

SELECT * FROM all_constraints WHERE constraint_name = 'PK_TABLENAME'