user1827527
user1827527

Reputation: 13

Oracle 10g Add primary key as sequence for existing table

I have three tables- Member,Payment,Award with over 3000 of records on them. At present Member table has memberId as a primary key and memberid is foreign key to Payment and Award tables. Note memberid is not auto generated field.This tables were created in Access. My job is to migrate into Oracle and add Primary key let's say mem_id as sequence number to the Member table and add mem_id as foreign key to Payment and Award tables.

So far it works good, Now my challenge to add Foreign key to Payment table as well as Award table - created the mem_id column in Payment table

       alter table PAYMENT
        add mem_id number Unique;

I get error ORA-00904 member.memberid: invalid identifier Need help to solve this problem.

Upvotes: 1

Views: 3316

Answers (1)

Jacob
Jacob

Reputation: 14731

Try updating PAYMENT table with the following

update payment p set p.mem_id  = (select mem_id from member where 
memberid = p.memberid);

Upvotes: 1

Related Questions