03 Structure Query Language
03 Structure Query Language
Query Language
DIT201 Database System
1
Struct Query Language
Database Server
DBMS
SQL
2
Types of Struct Query Language
3
Data Manipulation Language (DML)
Data Manipulation Language which deals with data
manipulation and includes most common SQL statements
● SELECT: Used to retrieve data from one or more database
tables based on specified conditions.
● INSERT: Used to add new records (rows) to a database table.
● UPDATE: Used to modify existing records in a database table.
● DELETE: Used to remove records from a database table.
4
Data Definition Language (DDL)
Data Definition Language, which deals with database schemas and
descriptions, of how the data should reside in the database.
● CREATE: to create new database objects, such as tables
● ALTER: alters the structure of the existing database object
● DROP: delete objects from the database
● TRUNCATE: remove all records from a table
5
Data Control Language (DCL)
Data Control Language which acts as an access specifier to
the database.
7
CREATE statement
CREATE: Used to create new database objects, such as tables,
views, indexes, and more. It defines the structure, data types,
and constraints for the object being created.
8
DROP mydb database if exists
9
CREATE DATABASE statement
CREATE DATABASE DatabaseName ;
10
CREATE TABLE statement
CREATE TABLE TableName (
DataName DataType ,
DataName DataType ) ;
2
11
ALTER statement
ALTER: Used to modify the structure of existing database objects.
You can use ALTER to add, modify, or delete columns, change
data types, or make other structural changes.
12
ALTER TABLE statement
ALTER TABLE TableName
13
ALTER TABLE statement
ALTER TABLE TableName
14
DROP statement
DROP: Used to delete database objects such as tables, views,
and indexes. Once an object is dropped, it is permanently
removed from the database.
15
DROP TABLE statement
DROP TABLE TableName ;
16
DROP DATABASE statement
DROP DATABASE DatabaseName ;
17
DON’T
18
Setup Learning Environment
Database Server
DBMS
19
Import Database
2
20
SELECT statement
SELECT: Used to retrieve data from one or more database tables
based on specified conditions. The SELECT statement allows you
to specify which columns to retrieve, filter data using conditions
(WHERE clause), and sort the results.
21
SELECT statement
SELECT DataName, DataName, [DISTINCT DataName ], [ function(DataName) ]
FROM TableName
[GROUP BY DataName ]
[LIMIT number]
[] : Optional statement
22
SELECT statement
SELECT *
FROM TableName ;
23
SELECT statement
SELECT DataName SELECT DataName
FROM TableName ;
24
SELECT statement
SELECT DataName, DataName
FROM TableName
25
SELECT statement
SELECT *
FROM TableName
ORDER BY DataName ;
26
INSERT statement
INSERT: Used to add new records (rows) to a database table. The
INSERT statement specifies the table and the values to be
inserted into each column.
27
INSERT statement
INSERT INTO TableName (DataName, DataName)
28
INSERT statement
INSERT INTO TableName
29
UPDATE statement
UPDATE: Used to modify existing records in a database table.
The UPDATE statement allows you to change the values of
specific columns based on specified conditions (WHERE clause).
30
UPDATE statement
UPDATE TableName
31
UPDATE statement
UPDATE TableName
32
DELETE statement
DELETE: Used to remove records from a database table. The
DELETE statement deletes rows that match certain conditions
specified in the WHERE clause.
33
DELETE statement
DELETE FROM TableName
34
DELETE statement
DELETE FROM TableName ;
If no conditions are specified will result in all Data cannot be deleted. In case the data is
table data being deleted. referenced for use in another table.
35
End.
DIT201
36