Skip to content

Commit 4995dd7

Browse files
authored
Merge pull request #3539 from Apoorva-Atre/newbranch
Added DML.md in DBMS
2 parents b43cd37 + 2374539 commit 4995dd7

File tree

1 file changed

+78
-0
lines changed
  • docs/DBMS/Structured Query Language

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Data Manipulation Language
2+
3+
DML is used for performing non-structural updates to a database. For example, adding a row to an existing table, retrieving data from a table, etc.
4+
5+
### DML commands include:
6+
- Select
7+
- Insert
8+
- Update
9+
- Delete
10+
11+
Let's see each command in detail:
12+
13+
## select
14+
15+
This command is used to retrieve data from the database. It is generally followed by from and where clauses.
16+
17+
Example:
18+
```sql
19+
select * from customers;
20+
```
21+
This query will return all the rows from the table customers including all attributes (columns).
22+
23+
```sql
24+
select *
25+
from customers
26+
where address="India";
27+
```
28+
This query will return all the rows where the address of the customer is India.
29+
30+
```sql
31+
select name,address
32+
from customers;
33+
```
34+
This type of query returns only the name and address of the customers, i.e. the required information, instead of returning all the information.
35+
36+
## insert
37+
38+
The insert command is used to add rows to a table in the database.
39+
40+
Example:
41+
```sql
42+
insert into customers values("Riya","India");
43+
```
44+
We can also insert multiple rows at a time:
45+
```sql
46+
insert into customers values
47+
("Riya","India")
48+
("Aditya","India")
49+
("Chris","Germany");
50+
```
51+
52+
## update
53+
54+
This command is used to update a certain row, given some information about that row.
55+
56+
Example:
57+
```sql
58+
update customers
59+
set name="Tanisha"
60+
where customer_id=125;
61+
```
62+
This query would update the name of the customer with id=125 to Tanisha.
63+
64+
## delete
65+
66+
Delete command is used to delete some rows in the table.
67+
68+
Example:
69+
```sql
70+
delete from customers where customer_id=125;
71+
```
72+
This will delete all the information of customer with id=125.
73+
74+
We can also delete multiple rows at a time:
75+
```sql
76+
delete from customers where address="India";
77+
```
78+
This query would delete information of all customers from India.

0 commit comments

Comments
 (0)