I have some data such as below:
full_name
R Davies
N Powell
Harry S
A J Fulham
I want to split the name from the first space and insert the values into forename and surname. so it will look like below:
forename surname
R Davies
N Powell
Harry S
A J Fulham
The code I have written is just to create the new columns and delete the old one. I have managed to create a select statement that will view the forename but I can't get it to insert. So I need the code to insert both values into the new columns as well as get the surname.
ALTER TABLE names add forename varchar(100)
ALTER TABLE names add surname varchar(100)
UPDATE names
INSERT INTO names(forename)
SELECT split_part(full_name, ' ', 1) FROM names
ALTER TABLE names DROP COLUMN full_name;