My Primary key constraint is mixed up. Pointing to a column in another table

32 Views Asked by At

I discovered this when I in IBConsole clicked on the table name and then on the data tab. No data was displayed.

I then tried to do the same with IBExpert. In this case an error message was displayed:

Column does not belong to referenced table. ... SQL error code = -206. Column unknown XEXCEDIADRID

Very strange because this column belongs to another table. I made a select on the table and got the correct answer. So the data is intact.

This is what the ddl of the table says:

CREATE GENERATOR GENMETODIDM;

CREATE TABLE METODMOT 
(
    METODID  INTEGER DEFAULT 0 NOT NULL,
    NAMN     VARCHAR(50) DEFAULT ' ' NOT NULL COLLATE SV_SV,
    DATA     VARCHAR(1000) DEFAULT ' ',
    KOMTYP   CHAR(4) DEFAULT 'SAKN',
    UPPLDAT  TIMESTAMP,
    ANDDAT   TIMESTAMP,
    USERID   VARCHAR(24),
    COMMENT  VARCHAR(1024) COLLATE SV_SV
);

ALTER TABLE METODMOT 
    ADD CONSTRAINT PKMM PRIMARY KEY (XEXCEDIADRID);

Is it possible to correct this problem in some way?

The correct PK is MetodId.

0

There are 0 best solutions below