Oracle Database Fundamentals - Updating Data (Page 5 of 5 )
We can update a table using following statements.
update tablename set columnname=somevalue;
Or
update tablename set columnname=somevalue where conditions;
To update all the records use the first statement. To update particular records, add where conditions at the end of the update statements. To give an increment of 1000 to all our employees use:
update employee set salary=salary+1000;
update employee set salary=60000 where empid=1;
The above statement will change the salary of employee with empid 1 to 60000.
Deleting Data
Data from tables can be deleted using the following statements.
delete from tablename;
delete from tablename where conditions;
delete tablename;
delete tablename where conditions;
To delete the record of an employee with the first name Tim use:
delete from employee where "First Name"='Tim';
To delete all records from the employee table use:
delete employee;
Dropping a Table
To drop a table use:
drop table tablename;
To drop an employee table use:
drop table employee;

To commit changes in Oracle Database use commit and to roll back your changes use the rollback command.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |