SQL Oracle Java JSP JDBC PHP MORE

Oracle query for UPDATE table data

To update existing records in a table UPDATE statement is used.

Oracle UPDATE Syntax

UPDATE table
SET column1 = value1,
column2 = value2,
...
column_n = value_n
WHERE conditions;

The WHERE clause specifies which record or records that should be updated. If you not write the WHERE clause query, all records will be updated.

Oracle Update Example: (Update single column)

UPDATE students
SET student_name = 'Mitra'
WHERE student_id = 2;

This example will update the student_name as "mitra" where "student_id" is 2.

Oracle Update Example: (Update multiple columns)

UPDATE students
SET student_address = 'Kendrapara',
student_name = 'Mitrabhanu'
WHERE student_id = 1;

Oracle Update Example: (By selecting records from another table)

UPDATE students
SET name = (SELECT student_name
FROM student
WHERE student.student_name = students.name)
WHERE age < 30;