I have a oracle table A which contains a column A.a which used to store an attribute of the table. It is a big table with data. Now the semantic requirement of attribute A.a needs to develop into another table called B, B has an id column, and a column B.a which stores the same set of data as A.a (both columns are unique).
So now A.a should upgrade to a foreign key of the table B, then A.a should store B.id instead of VARCHAR2 and also the more tough part is I need to use A.a to find B.id via B.a and rewrite A.a with B.id because table A has existing data.
And I have to achieve this via SQL query.
So how to get this work? Apologize if I didn’t make myself clear. Please feel free to leave any idea. Thanks in advance.
If you have the following schema:
You want to transform it to the following schema:
You can do it with something like the following sequence of commands: