SQL Certification - SPLessons

SQL Certification DML Commands

Home > Lesson > Chapter 13
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Certification DML Commands

DML Commands

shape Description

Data Manipulation Language is utilized to manage data within the table i.e., DML statements commands are used to manage data inside the schema objects, and includes most common standard query language statements such as select command and insert command. DML allows to add and modify the database table. Following are the DML statements commands:

Insert

shape Description

By using SQL Insert command new record can be inserted in the existing database table. i.e, inserting field value like emp_id, emp_name and salary can be inserted.

shape Syntax

Insert into <table_name> values(<value1>,<value2>,<value3>.......);
Table name =>The accurate table. values =>values are the column values.

shape Examples

By viewing the below example, the concept of insert command can be understood easily. [c]sql> create table employee23(emp_id number(4),ename varchar2(20),sal number); Query OK, 0 rows affected (0.32 sec) sql> insert into employee22 values(1001,'jack',12000); ERROR 1146 (42S02): Table 'employee.employee22' doesn't exist sql> create table employee24(emp_id number(4),ename varchar2(20),sal number); Query OK, 0 rows affected (0.63 sec) sql> insert into employee24 values(1001,'jack',12000); Query OK, 1 row affected (0.10 sec) sql> insert into employee24 values(1002,'mack',13000); Query OK, 1 row affected (0.39 sec) sql> select * from employee24; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | jack | 12000 | | 1002 | mack | 13000 | +--------+-------+-------+ 2 rows in set (0.00 sec)[/c] The above example tells that, when insert command is performed on the table employee24 then it will accept the values and stores in the table database.

Update

shape Description

By using SQL Update command, the column values can be updated i.e, changing the name of the employee and increasing/decreasing the salary. And the column parameters specifies the name of the columns of the table and the datatypes parameters specifies the type of data that the column is holding that may varies from varchar, decimal, date and integers.

shape Syntax

Update<table_name> set <column_name>=value where <condition>;
Table_name => Any accurate table. condition =>condition is a logic to get a specific record.

shape Examples

By viewing the below example, the concept of update command can be easily understand. [c]sql> select * from employee25; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | maddi | 12000 | | 1002 | jack | 13000 | +--------+-------+-------+ 2 rows in set (0.00 sec) sql> update employee25 set sal=sal+100 where ename='jack'; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 sql> select * from employee25; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | maddi | 12000 | | 1002 | jack | 13100 | +--------+-------+-------+ 2 rows in set (0.00 sec)[/c] The above example tells how to update the existing data from the table. i.e before updating the salary it was 13000 and after updating the result is 13100.

Delete

shape Description

By using SQL DELETE command rows can be deleted from an existing table taking into account the given condition.

shape Syntax

Delete from <table_name> where <condition>;
Table_name => Any accurate table. condition =>condition is a logic to get a specific record.

shape Examples

By viewing the below example, the concept of delete command can be easily understood. [c]sql> select * from employee25; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | maddi | 12000 | | 1002 | jack | 13100 | +--------+-------+-------+ 2 rows in set (0.00 sec) sql> delete from employee25 where ename='maddi'; Query OK, 1 row affected (0.16 sec) sql> select * from employee25; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1002 | jack | 13100 | +--------+-------+-------+ 1 row in set (0.00 sec)[/c] The above example tells that, when delete command is performed on a table employee25 and wants to delete ename=maddi, then it delete the entire details of maddi and gives the output of remaining employees in the table. 

Summary

shape Key Points

  • DML Commands - Used to manipulate the data in the database.
  • INSERT Statement - SQL INSERT Statement is utilized to insert the values inside the table.
  • Update Command - Update command is utilized to update the estimations of a current table values or protests.
  • SQL DELETE - Delete proclamation is utilized to erase a particular column value from the table.