Objectives:
a. Define what is SQL
b. Discuss the three group classification of SQL
Command
c. Create a Database using SQL command
e. Insert, Update and delete using sql command
What is SQL?
SQL or Structured Query
Language is a flexible language
that you can use to communicate
with a relational database
management system such as
MariaDB.
•SQL COMMANDS ARE CLASSIFY INTO THREE
GROUPS:
• Data Definition Language (DDL)
• Data Manipulation Language (DML)
• Data Control Language (DCL)
•Data Definition Language (DDL)
includes SQL commands that are used to
create database, modify its structure, and
destroy it when no longer need.
To Create Database
CREATE DATABASE <database_name>
CREATE DATABASE friends
To Drop Database DROP DATABASE
<database_name>
DROP DATABASE friends
CREATE TABLE table_name (
TO CREATE TABLE
Field1 datatype [constraints],
Field2 datatype [constraints],
:
:
Field3 datatype [constraints],
[Table constraints]
);
TO DROP TABLE
DROP TABLE <table_name>
DROP TABLE profile
Data Definition Language
• Data Manipulation Language (DML)
includes SQL commands that are used to
manage the contents of the database.
To Add new record in a
Table
INSERT INTO table_name (field1, field 2,field3)
VALUES (value1, value2,value3);
Example
Data Manipulation Language
TO MODIFY/UPDATE
EXISTING TABLE
UPDATE table_name
SET field1=value1, field2=value1,…
WHERE clause;
EXAMPLE
Data Manipulation
To Delete Records From
Language
Table
DELETE FROM table_name
[WHERE clause;]
Example
Data Manipulation
To Display records From Language
Table
SELECT [FIELDS] FROM table_name
[WHERE clause;]
Example
• Data Control Language (DCL)
includes SQL commands that are used to protect
your database from becoming corrupted.
We permit access to the database by using the
GRANT command and remove access by using
the REVOKE command
CREATE USER 'peter'@'localhost' IDENTIFIED BY 'peter';
GRANT USAGE ON *.* TO 'peter'@'localhost' IDENTIFIED BY
'peter';
GRANT ALL ON friends.* TO 'peter'@'localhost';
Activity no. 1
Create a Database using
SQL Command
TO CREATE A DATABASE USING SQL
TYPE: EX.
CREATE DATABASE SQLB3MUKATTIL
TO CREATE A DATABASE
USING SQL
TYPE:
CREATE DATABASE
SQL(Students
Lastname)
FIND YOUR DATABSE
NAME HERE THEN
CLICK
TYPE THIS SQL COMMAND TO CREATE A TABLE AND
FIELDS:
CREATE TABLE INVENTORY
(
Inventory_id INT AUTO_INCREMENT PRIMARY KEY,
Product_Name VARCHAR(100) not null,
Price DECIMAL (10,2) not null,
Stock_Quantity Int(30) not null,
Last_updated TIMESTAMP not null,
Supplier Varchar(70) not null
)
TYPE THIS SQL COMMAND TO CREATE A TABLE AND
FIELDS:
CREATE TABLE INVENTORY
(
Inventory_id INT AUTO_INCREMENT PRIMARY KEY,
Product_Name VARCHAR(100) not null,
Price DECIMAL (10,2) not null,
Stock_Quantity Int(30) not null,
Last_updated TIMESTAMP not null,
Supplier Varchar(70) not null
)
To insert data click
Symbols (‘’,’’,’’,’’,’’,’’)
YYYY-MM-DD HH-MM-SS