'; var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd(ad_id); });
Update command is a data manipulation command which is used to edit the records of a table. It may be used to update a single row based on a condition, all rows or set of rows based on the condition given by the user.
It is used along with the SET clause, operationally, a WHERE clause may be used to match conditions −
Example 1
An example is given below for the use of update command −
update table student set name=’sneha’ where branch=’CSE’;
Example 2
Given below is another example of the usage of update command −
create table employee(ename varchar(30),department varchar(20));insert into employee values('pinky','CSE');insert into employee values('priya','ECE');insert into employee values('hari','EEE');select * from employee;update employee set ename='sneha' where department='CSE';select * from employee;
Output
You will get the following output −
pinky|CSEpriya|ECEhari|EEEsneha|CSEpriya|ECEhari|EEE
Update the value of a column
Given below is an example to update table employee set age=age+1:
create table employee(ename varchar(30),department varchar(20), age number(30));insert into employee values('ram','projectmanager',40);insert into employee values('priya','assistant director',45);insert into employee values('hari','developer',46);select * from employee;update employee set age=age+2;select * from employee;
Output
You will get the following output −
ram|projectmanager|40priya|assistant director|45hari|developer|46ram|projectmanager|42priya|assistant director|47hari|developer|48
Update multiple columns in one statement
Given below is an example to update table salary set −
Here,
- bonus=bonus+5000
- basic=basic+(0.2*bonus)
Example
create table employee(ename varchar(30),department varchar(20), age number(30), salary number(20));insert into employee values('ram','projectmanager',40,50000);insert into employee values('priya','assistant director',45,45000);insert into employee values('hari','developer',46,30000);select * from employee;update employee set age=age+2, salary= salary+5000;select * from employee;
Output
You will get the following output −
ram |projectmanager |40|50000priya|assistant director|45|45000hari |developer |46|30000ram |projectmanager |42|55000priya|assistant director|47|50000hari |developer |48|35000
Related Articles
- Difference Between ALTER and UPDATE Command in SQL
- How to use update command in Android sqlite?
- What is the use of ALLOW_INVALID_DATES SQL mode?
- What is the use of IGNORE_SPACE SQL mode?
- What is the SQL command to return the field names of a table?
- What is the use of Get-Process command in PowerShell?
- What is the use of NO_UNSIGNED_SUBTRACT SQL mode in handling overflow?
- What is the difference between the New-AZTag and Update-AZTag command in Azure PowerShell?
- Show MySQL host via SQL Command?
- How to execute UPDATE SQL in a JSP?
- Explain the use of delete command in DBMS
- What is the equivalent of SQL “like” in MongoDB?
- What is SQL?
- How to execute SQL update query in a JSP?
- What is the purpose of the command interpreter?
Advertisem*nts
';adpushup.triggerAd(ad_id); });