DBMS Experimentdbms-4
DBMS Experimentdbms-4
Aim: To study the various DML commands and implement them on the database.
Tools/ Apparatus:
HARDWARE REQUIREMENTS:
80GB HDD
512MB DDR
SOFTWARE REQUIREMENTS:
ORACLE 10g
Procedure:
To study the various DML commands and implement them on the database.
DML COMMANDS
DML commands are the most frequently used SQL commands and is used to query and
manipulate the existing database objects. Some of the commands are Insert, Select, Update, Delete.
Insert Command This is used to add one or more rows to a table. The values are separated by
commas and the data types char and date are enclosed in apostrophes. The values must be entered in
the same order as they are defined.
Select Commands It is used to retrieve information from the table. It is generally referred to as
querying the table. We can either display all columns in a table or only specify column from the
table.
Update Command It is used to alter the column values in a table. A single column may be updated or
more than one column could be updated.
Delete command After inserting row in a table we can also delete them if required. The delete
command consists of a from clause followed by an optional where clause.
In SQL, the SELECT statement is used to query or retrieve data from a table in the database. The
returns data is stored in a table, and the result table is known as result-set.
Syntax
To fetch the EMP_ID of all the employees, use the following query:
The SQL INSERT statement is used to insert a single or multiple data in a table. In SQL, you can insert
the data in two ways:
If you want to specify all column values, you can specify or ignore the column values.
Syntax
To insert partial column values, you must have to specify the column names.
Syntax
Ex. INSERT INTO EMPLOYEE (EMP_ID, EMP_NAME, AGE) VALUES (7, 'Jack', 40);
3. SQL Update Statement-
The SQL UPDATE statement is used to modify the data that is already in the database. The condition
in the WHERE clause decides that which row is to be updated.
Syntax
UPDATE <table_name>
WHERE <condition>;
Ex. Update the column EMP_NAME and set the value to 'Emma' in the row where SALARY is
500000.
Syntax
UPDATE <table_name>
WHERE <condition>;
If you want to update multiple columns, you should separate each field assigned with a comma. In
the EMPLOYEE table, update the column EMP_NAME to 'Kevin' and CITY to 'Boston' where EMP_ID
is 5.
Syntax
UPDATE <table_name>
WHERE <condition>;
If you want to update all row from a table, then you don't need to use the WHERE clause. In the
EMPLOYEE table, update the column EMP_NAME as 'Harry'.
Syntax
UPDATE <table_name>
The SQL DELETE statement is used to delete rows from a table. Generally, DELETE
statement removes one or more records form a table.
Syntax
Delete the row from the table EMPLOYEE where EMP_NAME = 'Kristen'. This will delete
only the fourth row.
Delete the row from the EMPLOYEE table where AGE is 30. This will delete two rows(first and third
row).
Delete all the row from the EMPLOYEE table. After this, no records left to display. The
EMPLOYEE table will become empty.
Syntax
Memory Table memory space is not free if Drop command frees the memory space.
5 Space all records are deleted using Delete
Command.
Problem DELETE command may face DROP Command may cause memory
6
shortage of memory. fragmentation.
Interaction SQL directly interacts with database PL/SQL does not directly interacts with
6
server. database server.
Objective SQL is used to write queries, create PL/SQL is used to write program blocks,
8 and execute DDL and DML functions, procedures, triggers and
statments. packages.
Assignment-
Q2: Insert more than a record into emp table using a single insert command.
Q3: Update the emp table to set the salary of all employees to Rs15000/- who are living in sikar.
Q4: Create a pseudo table emp1 with the same structure as the table emp .
Q7: List the records in the emp table orderby salary in ascending order.
Q8: List the records in the emp table orderby salary in descending order.
Q10: Display name from the table emp avoiding the duplicated values.
Solution: