DML Commands Exp 5
DML Commands Exp 5
DML Commands Exp 5
(OR)
Inserting records dynamically
Oracle provides substation variables method to insert the records dynamically
Syntax :
INSERT INTO <table_name> values( &col1, &col2, &col3, …, …., …. ) (or)
&Var1, &var2, &var3, …, …., …. )
Note : The column or variable name should be in single quotations for char and date type data
Syntax :
UPDATE <table_name> SET Col1 = value, Col2=value, Col3=val
In the above statement if we did not give the where condition then all
employees salary will be raised by Rs. 500. That’s why always specify proper
WHERE condition if don’t want to update all employees.
For example We want to change the name of employee no 102 from ‘Sami’
to ‘Mohd Sami’ and to raise the salary by 10%. Then the statement will be.
Ex:
mysql> update emp set name=’Mohd Sami’,
sal=sal+(sal*10/100) where empno=102;
DELETING RECORDS FROM THE TABLE
Syntax:
DELETE FROM <table_name> ; to delete all records from the table
Ex:
mysql> Delete from emp;
it will delete all records from table
Use the DELETE statement to delete the rows from existing tables which are
in your schema or if you have DELETE privilege on them.
LAB PRACTICE:
mysql>desc dept;