Data Manipulation Language
INSERT STATEMENT:
The INSERT statement is used to add new row in database table.
INSERT Type 1:
INSERT IINTO Table_name Values(column1_value,column2_value,column3_value,______)
In this type values insert into all column in table.
Employee
id | Emp_name | Age | Salary | Dept_id |
1 | Jebas | 35 | 80000 | 2 |
2 | Thomas | 30 | 40000 | 1 |
3 | Mark | 25 | 40000 | 2 |
4 | Harry | 42 | 62500 | 2 |
5 | Willam | 45 | 125000 | 1 |
6 | James | 32 | 35000 | 3 |
7 | Mock | 22 | 15000 | 3 |
INSERT INTO Employee VALUES('Sherin',23,14000,7);
Employee
id | Emp_name | Age | Salary | Dept_id |
1 | Jebas | 35 | 80000 | 2 |
2 | Thomas | 30 | 40000 | 1 |
3 | Mark | 25 | 40000 | 2 |
4 | Harry | 42 | 62500 | 2 |
5 | Willam | 45 | 125000 | 1 |
6 | James | 32 | 35000 | 3 |
7 | Mock | 22 | 15000 | 3 |
8 | Sherin | 23 | 12000 | 7 |
INSERT TYPE 2.
INSERT INTO Table_name (column1,column2, column3_____) Values(column1_value,column2_value,column3_value,______)
In this type the value insert only specified column in table.
INSERT INTO Employee (Emp_name,Age,salary,dept_id) VALUES('MOSES',26,20000,6);
Employee
id | Emp_name | Age | Salary | Dept_id |
1 | Jebas | 35 | 80000 | 2 |
2 | Thomas | 30 | 40000 | 1 |
3 | Mark | 25 | 40000 | 2 |
4 | Harry | 42 | 62500 | 2 |
5 | Willam | 45 | 125000 | 1 |
6 | James | 32 | 35000 | 3 |
7 | Mock | 22 | 15000 | 3 |
8 | Sherin | 23 | 12000 | 7 |
9 | MOSES | 26 | 20000 | 6 |
UPDATE STATEMENT:
The update statement will update or modify one or more column in database table. The update is used along with where clause to update only specified column.
UPDATE table_name SET Column=value WHERE Condition
In this type, it update only one column.
UPDATE Employee SET salary=21000 where id=9;
UPDATE table_name SET Column1=value, Column2=value,
Column3=value,____WHERE Condition.
UPDATE Employee SET salary=23000,dept_id=4 where id=9
In this type, it update multiple column at one time.
Employee
id | Emp_name | Age | Salary | Dept_id |
1 | Jebas | 35 | 80000 | 2 |
2 | Thomas | 30 | 40000 | 1 |
3 | Mark | 25 | 40000 | 2 |
4 | Harry | 42 | 62500 | 2 |
5 | Willam | 45 | 125000 | 1 |
6 | James | 32 | 35000 | 3 |
7 | Mock | 22 | 15000 | 3 |
8 | Sherin | 23 | 12000 | 7 |
9 | MOSES | 26 | 23000 | 4 |
Be careful when update statement, when update without where condition
UPDATE Employee set emp_name='jebas';
It will update all emp_name to jebas.😀;
DELETE STATEMENT.
The DELETE Statement used to delete record or row from database table.
DELETE table_name WHERE Column_value CONDITION
DELETE From Employee WHERE id=8;
This delete statement will remove entire row of id=8;
Employee
id | Emp_name | Age | Salary | Dept_id |
1 | Jebas | 35 | 80000 | 2 |
2 | Thomas | 30 | 40000 | 1 |
3 | Mark | 25 | 40000 | 2 |
4 | Harry | 42 | 62500 | 2 |
5 | Willam | 45 | 125000 | 1 |
6 | James | 32 | 35000 | 3 |
7 | Mock | 22 | 15000 | 3 |
9 | MOSES | 26 | 23000 | 4 |
The DELETE statement without where class will delete entire table.
DELETE FROM Employee;
Employee
id | Emp_name | Age | Salary | Dept_id |
DROP Statement.
The DROP Statement will delete the entire table itself.
DROP Table_name;
DROP Employee.
Thank You. Like Share and Subscribe 👍 folowlect.com
Comments
Post a Comment