I have two tables as shown below (only relevant columns shown). The
second table is dependent on the first one.
CREATE TABLE PARENTTABLE (
...
SERIAL CHAR(12) NOT NULL,
ENDDATE TIMESTAMP NOT NULL,
PKLINK INTEGER GENERATED ALWAYS AS IDENTITY (START WITH -2147483648,
INCREMENT BY 1),
PRIMARY KEY (PKLINK),
CONSTRAINT CONSTRAINT1 UNIQUE (ENDDATE,SERIAL )
) DATA CAPTURE NONE IN USERSPACE1;
CREATE TABLE CHILDTABLE (
...
PKLINK INTEGER NOT NULL,
PACKET SMALLINT NOT NULL,
PRIMARY KEY (PKLINK,PACKET) ,
FOREIGN KEY(PKLINK) REFERENCES PARENTTABLE(PKL INK) ON DELETE CASCADE
) DATA CAPTURE NONE IN USERSPACE1;
My problem is that when I do a "SELECT * FROM PARENTTABLE WHERE
ENDDATE BETWEEN ...", the query is very slow. It seems that the
constraint on this table is not work. I would like to remove the
constraint and create a unique index instead. Questions:
(1) How do I remove the constraint in the first table? I can't do an
explicit DROP on the constraint.
(2) If I need to recreate the table, I would have to export out the
data first and later import back the data into the new table (without
the contraint). Will the identity column (PKLINK) prevent me from
importing the data? I still want the old values of the identity column
because the second table depends on it. What can I do to successful
import the data?
Thanks in advance.
Yong Sing