The UPDATE statement is used to update existing records in a table.
General syntax:
UPDATE table_name
SET column1=values
where some_column=some_values;
SQLselect * from test;
ID NAME EMAIL
---------- --------------------
1 Eve [email protected]
2 Jon [email protected]
3 Mike
--first lets drop the table Test (if she exists, if not skip the drop line).Drop table test;
--we create the table;
create table test (id int,name varchar2(20),email varchar2(20));
--we insert values into our table .
insert into test values (1,'Eve','[email protected]');
-- insert with no condition ( insert all values)
insert into test values (2,'Jon','[email protected]');
-- insert with no condition ( insert all values)
insert into test(id,name) values (3,'Mike');
-- insert with no condition ( insert only declared values)
insert into test(name) values ('Paul');
-- insert with no condition ( insert only declared values)
Sql :select * from test;
- It should be like
ID NAME EMAIL
---------- --------------------
1 Eve [email protected]
2 Jon [email protected]
3 Mike
4 Paul
SQL
update test set email ='[email protected]' where id=3;
SQL
select * from test;
ID NAME EMAIL
---------- -------------------- --------------------
1 Eve [email protected]
2 Jon [email protected]
3 Mike [email protected]
4 Paul
SQLupdate test set id=4
email='[email protected]'
where name='Paul';
SQLselect * from test;
ID NAME EMAIL
---------- -------------------- --------------------
1 Eve [email protected]
2 Jon [email protected]
3 Mike [email protected]
4 Paul [email protected]
SQLupdate test set id=4 , email='[email protected]' ;
SQL
select * from test;
ID NAME EMAIL
-------- ---------------- --------------------
4 Eve [email protected]
4 Jon [email protected]
4 Mike [email protected]
4 Paul [email protected]