one to one relatioship [message #329308] |
Wed, 25 June 2008 00:28 |
kris123
Messages: 5 Registered: June 2008
|
Junior Member |
|
|
Hi
I have a big table with row size 50000bytes.I want to split into three tables with one-to one.I have empid pk in the main table do all table shall have this field.how do i keep relationship with other tables.Do I need to connect each one with all dependents
|
|
|
|
Re: one to one relationship [message #329824 is a reply to message #329308] |
Thu, 26 June 2008 12:03 |
hhelgen
Messages: 12 Registered: April 2007 Location: Duluth MN
|
Junior Member |
|
|
Create your other two tables with a primary key of empid. Also, make the empid in the second and third table a foreign key to the main table.
Then split your columns into the second and third tables. Try code something like this to create the second table. Backup or export your schema just in case. Copy the data from the first table columns into the same columns in the second table. The drop the columns from the first table.
CREATE TABLE MYSCHEMA.EMPLOYEE2 (EMPID VARCHAR2(10) NOT NULL,
COLUMNAFROMTABLE1 VARCHAR2(10) NOT NULL,
COLUMNBFROMTABLE1 VARCHAR2(10) NOT NULL,
PRIMARY KEY(EMPID),
CONSTRAINT FK_EMP1_EMP2 FOREIGN KEY(EMPID)
REFERENCES MYSCHEMA.EMPLOYEE(EMPID))
TABLESPACE USR;
|
|
|