TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Oracle Update

Oracle Update Query for beginners and professionals with examples on insert, select, update, delete, table, view, join, key, functions, procedures, indexes, cursor etc.

<< Back to ORACLE

Oracle UPDATE Statement

In Oracle, UPDATE statement is used to update the existing records in a table. You can update a table in 2 ways.

Traditional Update table method

Syntax:

UPDATE table
SET column1 = expression1,
    column2 = expression2,
    ...
    column_n = expression_n
WHERE conditions;

Update Table by selecting rocords from another table

Syntax:

UPDATE table1
SET column1 = (SELECT expression1
               FROM table2
               WHERE conditions)
WHERE conditions; 

Parameters:

1) column1, column2, ... column_n:

It specifies the columns that you want to update.

2) expression1, expression2, ...expression_n:

This specifies the values to assign to the column1, column2, ?. column_n.

3) conditions:It specifies the conditions that must be fulfilled for execution of UPDATE stateme.

Oracle Update Example: (Update single column)

UPDATE suppliers
SET supplier_name = 'Kingfisher'
WHERE supplier_id = 2;

This example will update the supplier_name as "Kingfisher" where "supplier_id" is 2.

Oracle Update Example: (Update multiple columns)

The following example specifies how to update multiple columns in a table. In this example, two columns supplier_name and supplier_address is updated by a single statement.

UPDATE suppliers
SET supplier_address = 'Agra',
    supplier_name = 'Bata shoes'
WHERE supplier_id = 1;

Output:

1 row(s) updated.
0.06 seconds

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

UPDATE customers
SET name = (SELECT supplier_name
                 FROM suppliers
                 WHERE suppliers.supplier_name = customers.name)
WHERE age < 25;

Output:

2 row(s) updated.
0.02 seconds

Here, the customers table is updated by fetching the data from "suppliers" table.





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf