Chapter Two SQL Course 3
Chapter Two SQL Course 3
Labaad
SQL Course
Semester Four
Chapter TWO
DDL & DML
SQL Commands
SQL Commands are instructions that are used by the user to communicate with the
database, to perform specific tasks, functions and queries of data
Koowaad
Qaybta
Section ONE
Data Definition Language
Data Definition Language update
DDL is used to define and modify database structures.
CREATE Command
The CREATE statement in SQL is used to create new databases, tables, indexes, or other
database objects. The most commonly used form is CREATE TABLE, which defines a
new table and its columns.
• Table
• Database
• Views
CREATE Command
Before creating tables, we first need to create a database where all the tables will be
stored.
command
object obsactama
a
Create Database School
command
tama
keyword object
USE School
command
CREATE Command - Tables
The ALTER statement is used to modify an existing table structure without deleting or
recreating it. It allows us to add, delete, or modify columns and constraints
in a table
The ALTER statement is used to modify an existing table structure without deleting or
recreating it. It allows us to add, delete, or modify columns and constraints
in a table
The DROP statement is used to remove objects like databases, tables, columns,
or constraints permanently from the database.
Dropping a Database
Dropping a Table
Section Two
Data Manipulation Language
Data Manipulation Language
DML
The SELECT command is used to query the database and retrieve data from one or
more tables
If you want to select all columns from a table, use the asterisk * symbol:
This will retrieve the StudentName, Age, and Class columns from the Students table.
SELECT with WHERE Clause (Filtering Data)
The WHERE clause is used to filter records based on a condition. For example, to
select students who are 20 years old or older
This will retrieve the StudentName and Age of students who are 20 years old or older
saddataad
Qousta
Section Three
ALIAS
I
myonal
Magac
Nama
Fake
ALIAS
Aliases
Column Table
Column ALIAS
Aliases
Column Table
four
r
Section SQL Operators
AFaraad
Qaybta
Operators in SQL
Operators
This query selects all records from the CUSTOMERS table where the salary is
NOT 2000.
SQL Logical Operators
• Here is a list of all the logical operators available in SQL
SQL Comparison Operators
This query selects all customers from the CUSTOMERS table whose name starts with 'Ko'
using the LIKE operator. The % wildcard allows for any characters to follow the 'Ko'
Retrieving Customers Aged Between 25 and 27
This query selects all records from the CUSTOMERS table where the age is between 25
and 27, inclusive, using the BETWEEN operator
isatto Xig to waxaa
Nasiib vacancy