The question is published on by Tutorial Guruji team.
I have created a new column in Oracle but I need to append the new data to the already existing records is there a simple method for this.
I have tried the insert method but this only applies the data after the already created data.
INSERT INTO BOOKINGS (DATE_BOOKED) VALUES (to_date ('01/01/2012 6:49 PM','DD/MM/YYYY HH.MIPM'));
I am just unsure of how to append 1561 rows of data the table headers are as such
BOOKINGS_ID, GUEST_ID, ROOM_NO, OCCUPANTS, NIGHTS, RATE, ROOM_TYPE, DATE_BOOKED
any help is greatfully appreciated
If I understand you correctly, you don’t want to insert new rows, but you want to update (change) the existing ones. This is done using the
UPDATE statement, not
UPDATE bookings SET date_booked = to_date ('01/01/2012 6:49 PM','DD/MM/YYYY HH.MIPM'); COMMIT;
This will set the value for the column
date_booked to the same value for all existing rows.
You might want to consider going back to your SQL tutorial to understand the difference between
To update only a single row, you need to add a
WHERE clause that will limit the update to one row:
UPDATE bookings SET date_booked .... WHERE bookings_id = 1; UPDATE bookings SET date_booked = .... WHERE bookings_id = 42;
(assuming bookings_id is the primary key of the table)