Professional Documents
Culture Documents
Database
SQL LANGUAGES
Fundamentals
DML
• SELECT
“ D ata • INSERT
M anipulation • UPDATE
L anguage ” • DELETE
2
DML
3
INSERT
“The INSERT INTO statement of SQL is used to insert a new row in
a table.”
There are two ways of using INSERT INTO statement for inserting rows:
1. Only values: First method is to specify only the value of data to be inserted
without the column names.
4
2. Column names and values both: In the second method we will specify both the columns which we
want to fill and their corresponding values as shown below:
5
DELETE
6
DELETE
Syntax: Basic
Note:
We can delete single as well as multiple records depending on the condition we
provide in WHERE clause.
If we omit the WHERE clause then all of the records will be deleted and the
table will be empty.
7
UPDATE
8
UPDATE
UPDATE table_name SET column1 = value1, column2 =
value2,... WHERE condition;
NOTE:
In the above query the SET statement is used to set new values to
the particular column and the WHERE clause is used to select the
rows for which the columns are needed to be updated.
If we have not used the WHERE clause then the columns in all the
rows will be updated. So the WHERE clause is used to choose the
particular rows.
9
DDL
“Data Definition Language(DDL) is a
subset of SQL and a part
of DBMS(Database Management
System). DDL consist of Commands to
commands like CREATE, ALTER,
TRUNCATE and DROP. These
commands are used to create or
modify the tables in SQL.”
Syntax :
Syntax :
13
DRO
P
This command is used to remove an existing table
along with its structure from the Database.
Syntax
14
INNER JOIN
The INNER JOIN selects all rows from both
participating tables as long as there is a
match between the columns.
15
Inner Join
Pictorial presentation of SQL Inner
Join:
16
SELECT columns
FROM table1
INNER JOIN table2
ON table1.column_name =
Syntax table2.column_name;
17
Example
SELECT Customer.customer_id, Customer.first_name, Order.amount
FROM Customers
INNER JOIN Orders
ON Customers.customer_id = Orders.customer;
18
Customer
Customer_id First_name Order
1 John
Order_id amount customer
2 Robert
1 200 10
3 David
4 John 2 500 3
5 Betty 3 300 6
4 800 5
5 150 8
19