Professional Documents
Culture Documents
objectives :
*list the types of dml commands
*state & demonstrate the use of insert command
*state & demonstrate the use of update command
*state & demonstrate the use of delete command
sql-dml
*commands used to manipulate the data in the
database
dml - insert
*inserting data / values into a table :
*all rows in a table are inserted using the insert command
*syntax :
insert into <table name> [(col1, col2, ….)]
values (<list of values>);
*values for all the columns or selected columns can be
inserted
*if column names are omitted the values should be in exactly
same order
*columns that exists in the table but that are not listed in the
insert default to null
*character & date data is enclosed within single quotes
*null values are given as null
*example :
*inserting all values
insert into emp
values (7315, `john’, `clerk’, 7801, `10-jun-97’, 2500, null, 30);
*inserting only some values
insert into emp (empno, ename,sal) values (8234, `samuel’,
6000);
dml - insert
*values can also be given through a query, if so
columns of table must be match the column output
of the query
*values can also be substituted using parameter
substitution
*also used to copy rows or partial rows from one
table to another table
*values clause is replaced by query using select
clause
*syntax:
insert into <table name> [(col1, col2, ….)]
select statement;
*example :
1. insert the records of all manager’s into incr table
with an increment of 300.
dml-insert
*parameter substitution provides an easier way to
enter data into a table
*the `&’ symbol is used as the substitution operator
*when a substitution operator is used sql*plus
prompts for the value of the variable
*examples :
*insert a row into emp table using parameters
substitution.
*syntax :
update <table_name>
set <col_name> = <value>
[where <condition>];
dml - update
examples :
1. increase salary of all the employees by 15%.
dml - delete
*rows can be deleted using delete statement
*the entire row is deleted from the table
*set of rows can also be deleted from a table by
specifying the condition(s)
dml - delete
*syntax :
delete [from] <table_name> [where<condition>];
*examples :
1. delete all the details of `miller’.
2. delete the records of clerks.
3. delete the records of employees who have not got
increment.
transaction processing
*what are transactions?
*transaction is a series of operations treated as a single
logical unit
transaction processing
*transaction categories :
*ddl transactions
*implicit
*dml transactions
*explicit
transaction commands
*commit
*rollback
commit
*commitcommand makes changes permanent to the
database
*syntax :
commit [work];
rollback
*changes made in the transactions can be undone
*the complete transaction is undone
*rollback restores data to the pre-transaction state
*syntax :
rollback [work];
rollback
*as a result of rollback
*the current transaction is ended
*a new transaction is started
*any locks acquired are released
*in case of system failure, the transaction is undone
(implicit rollback)
partial transactions: savepoint
*transactions can be divided in to smaller portions
using save points
*savepoint is a kind of bookmark
*syntax :
savepoint <save_point_name>;
*syntax :
rollback [work] to save_point_name;