SQL Server by ThePhenomenal
SQL Server by ThePhenomenal
Introduction
- Definition of SQL:
o SQL stands for Structured Query Language, it`s used to access and modify information or
data from a database
- Definition of DDL : data definition language
o Create
Create command Syntax for database
CREATE DATABASE-name such as “CREATE DATABASE
Phenomenal”
o USE
the use command Syntax
USE DATABASE-name such as “USE DATABASE Phenomenal”
o ALTER
The Alter command is used to modify the structure of table without deleting.
We can use ADD and MODIFY command with ALTER command such
as
ALTER TABLE –NAME such as ALTER TABLE Students
ALTER COLUMN name TEXT
o DROP
The drop command is used to remove the database object from DBMS, and
delete the table from the database
DROP COMMANS syntax
o DROP DATABASE-name
DROP School
DROP TABLE table-name
DROP TABLE Student
- TRUNCATE TABLE
o The TRUNCATE TABLE command used to delete all the rows/records from the entire
table
the truncate command also removes the index from the column
TRUNNCATE syntax
TRUNNCATE TABLE table-name
- Definition of DML: Data Manipulation language, the DML statement include four main
commands
o SELECT:
The SELECT command is used to retrieve data from tables
o INSERT
The INSERT command is used to insert new data into tables
o UPDATE
The UPDATE command is used to modify existing data in tables
o DELETE
The DELETE command is used to remove existing records from tables
.
.
Written by: The Phenomenal One private property Stick to the Code
MySQL server 2k08
Written by: The Phenomenal One private property Stick to the Code
MySQL server 2k08
.
SQL OPERATORS
o SQL LIKE OPERATOR
o SQL IN OPERATOR
o SQL BETWEEN OPERATOR
o SQL AND / OR OPERATOR
CHAPTER 2
The SQL AND, OR, NOT Operators
- The WHERE Clause can be combined with AND, OR , and NOT Operators
- The AND & OR operator are used to filter records based on more than one condition
o The AND operator display a record if all the conditions separated by AND is True
o The OR operator displays a record if any of the conditions separated with OR is
True
AND Syntax
SELECT Col1, Col2 … FROM table-name WHERE Condition1
AND Condition2 AND Condition3 …;
OR Syntax
SELECT Col1, Col2 … FROM table-name WHERE Condition1 OR
Condition2 OR Condition3 …;
NOT Syntax
SELECT Col1, Col2 … FROM table-name WHERE NOT
Condition;
SQL BETWEEN Operator
- The BETWEEN operator selects values within a given range. The values can be numbers
text, or dates
o The BETWEEN operator is inclusive: begin and end values are included.
BETWEEN Syntax
Written by: The Phenomenal One private property Stick to the Code
MySQL server 2k08
Written by: The Phenomenal One private property Stick to the Code