Take this for example:
I have a old table with movies. And now I want split this table in a movie table and a genre table.
In the old table I have a column with genres. I want to move them to another table genres. And store the id in the movie table and not the name of the genre.
So I need a sql query that goes trough my old table record by record. Store all the fields without the genre field in my new movie table. And add the genre name from my old table in the genre table and give the auto generate primary key to the new movie table. If the genre already exist in the genre table I don't need to create the genre so I only have to give the corresponding id to the new movie table.
Is that possible using sql and how?
I’m working with DB2.
I have a old table with movies. And now I want split this table in a movie table and a genre table.
In the old table I have a column with genres. I want to move them to another table genres. And store the id in the movie table and not the name of the genre.
So I need a sql query that goes trough my old table record by record. Store all the fields without the genre field in my new movie table. And add the genre name from my old table in the genre table and give the auto generate primary key to the new movie table. If the genre already exist in the genre table I don't need to create the genre so I only have to give the corresponding id to the new movie table.
Is that possible using sql and how?
I’m working with DB2.