All DML Statement in SQL, Select Statement, Delete, Insert and Update Statement
Data Manipulation Language – DML Statements
Data Manipulation Language (DML) statements get to and control information in existing diagram objects. These queries don’t verifiably confer the present exchange. The information control dialect statements are:
Select Statement
The SELECT statement is a constrained type of DML articulation in that it can just get to information in the database. It can’t control information in the database, in spite of the fact that it can work on the information prior to giving back the results of the query.
Syntax
select * from tbl_name where <condition> order by <sort>
Example
Select * from USERS where ID = 1
ID | Name | UName | PWord | Status |
1 | Tom Brown | t.brown | myPass | 1 |
Insert Statement:
Insert statement is used to insert data into a table.
Syntax
Insert into tbl_name values (val1, val2, val3,…, val_n)
Example
Insert into users values (3, ‘Tim Robbins’, ‘t.robbins’, ‘password’, 1
The above command will insert a record into Users table.
ID | Name | UName | PWord | Status |
3 | Tim Robbins | t.robbins | P@ssW0rd | 1 |
Example to Insert NULL value to a column
Both the statements below will insert NULL value into PWord column of the Users table.
insert into USERS(id,Name,UName,Status) values(3,’Tim Robbins’,’t.robbins’,1);
Or,
insert into USERS values(4,’Jack’,’jack’, Null,1);
The above command will insert only two column value other column is set to null.
ID | Name | UName | PWord | Status |
3 | Tim Robbins | t.robbins | | 1 |
4 | Jack | jack | | 1 |
Update Statement
Update command is used to update a row of a table.
Syntax
Update tbl_name set col_name = value where condition;
Example
update users set PWord=’password’ where id=3;
ID | Name | UName | PWord | Status |
3 | Tim Robbins | t.robbins | password | 1 |
Delete Statement
Delete command is used to delete data from a table. Delete command can also be used to delete row(s) matching a particular condition. Following is its general syntax,
Syntax
delete from tbl_name;
Example
Delete from users;
The above command will delete all the records from Users table.
Example to delete a particular Record from a Table
Consider the following Users table
ID | Name | UName | PWord | Status |
3 | Tim Robbins | t.robbins | | 1 |
4 | Jack | jack | | 1 |
delete from users where id=3;
The above command will delete the record where id is 3 from Users table.
ID | Name | UName | PWord | Status |
4 | Jack | jack | | 1 |
More Related Articles For You
- Architecture of DBMS
- CODDS RULE DBMS
- Database Models in DBMS
- Relational DBMS Concepts
- Keys and Types of keys in Database
- Database Normalization
- Generalization, Specialization and Aggregation Concepts in DBMS
- ERD Diagram Tutorial with Examples in DBMS
- Introduction to SQL
- How to Create Query in SQL, Create Table, Delete Table and User Insert Info Statements
- Alter Query Command in SQL, Add, Modify and Drop Column in Table
- TCL Commands in SQL
- Truncate Query, Drop and Rename Query in SQL
- Data Control Language DCL Revoke and Grant Command in SQL
- Select Statement or Select Query in SQL Explained with Examples
- Distinct Keyword Explained in SQL
- WHERE Statement or WHERE Clause in SQL Statement Explained
- AND & OR Operators in SQL
- LIKE Operator in SQL
- ORDER BY Clause Sorting Explained in SQL
- Group By Clause in SQL
- Having Clause Explained in SQL
- SQL Constraints
- SQL Aggregate Functions
- SQL Aliases Use and Purpose in SQL
- SQL Joins Types, Use and Purpose
- SQL Sequence Syntax and Use with Examples
- SQL View
- SET Operation in SQL, UNION, UNION ALL, Intersect and Minus