AST110 DATA ANALYTICS
SQL (STRUCTURE
QUERY LANGUAGE)
COLLEGE OF ENGINEERING TECHNOLOGY
What is SQL?
SQL stands for Structured Query Language.
It is a standard language used for accessing
and manipulating databases.
SQL allows you to perform various operations
on databases, such as querying data,
inserting records, updating data, and more.
It became an ANSI (American National
Standards Institute) standard in 1986 and an
ISO (International Organization for
Standardization) standard in 1987.
WHAT CAN SQL DO?
Query Execution: SQL can execute Stored Procedures: SQL allows you
queries against a database to retrieve to define and use stored procedures.
specific data. Views: SQL can create views, which
Data Retrieval: You can use SQL to are virtual tables based on existing
retrieve data from a database. data.
Data Modification: SQL enables you to Permissions: You can set
insert, update, and delete records in permissions on tables, procedures,
a database. and views.
Database Creation: SQL can create
new databases.
Table Creation: You can create new
tables within a database.
STANDARD AND VARIATIONS:
While SQL is an ANSI/ISO standard, Major commands like SELECT, UPDATE,
different database systems have their DELETE, and INSERT are supported
own proprietary extensions in addition across most SQL implementations.
to the standard commands.
Popular RDBMS (Relational Database Management Systems) that use SQL include MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft
Access.
FEATURES
It serves as the foundation
for SQL and modern
database systems.
Data in an RDBMS is
stored in tables, which
RDBMS AND TABLES
consist of columns (fields)
and rows (records). RDBMS stands for
Relational Database
Each record represents an Management System.
individual entry in the table.
For example, consider the
“Customers” table with fields
like CustomerID,
CustomerName,
ContactName, Address, City,
PostalCode, and Country
SQL is a fundamental language
for anyone working with
databases, whether you’re a
developer, data analyst, or
database administrator. It
empowers you to manage and
manipulate data efficiently!
INSTALLING SQL SERVER ON WINDOWS INVOLVES A FEW STEPS. LET’S
EXPLORE HOW YOU CAN DO IT:
SQL
1. DOWNLOAD SQL SERVER:
VISIT THE OFFICIAL SQL SERVER DOWNLOAD PAGE PROVIDED
BY MICROSOFT.
CHOOSE THE EDITION YOU WANT TO DOWNLOAD. FOR FREE
USE, THE EXPRESS EDITION IS A GOOD CHOICE.
CLICK THE DOWNLOAD NOW LINK BELOW YOUR SELECTED
EDITION.
THIS WILL DOWNLOAD THE INSTALLATION WIZARD FOR SQL
SERVER
INSTALLATION PROCESS:
ONCE THE DOWNLOAD IS COMPLETE, OPEN THE INSTALL FILE TO
SQL
START THE SETUP.
CHOOSE AN INSTALLATION LOCATION AND CLICK INSTALL TO
CONTINUE.
WAIT FOR THE INSTALLATION PROCESS TO COMPLETE.
FINALLY, CLICK CLOSE TO EXIT THE SETUP
SQL
INSTALLATION PROCESS:
ONCE THE DOWNLOAD IS COMPLETE, OPEN THE INSTALL FILE TO
START THE SETUP.
CHOOSE AN INSTALLATION LOCATION AND CLICK INSTALL TO
CONTINUE.
WAIT FOR THE INSTALLATION PROCESS TO COMPLETE.
FINALLY, CLICK CLOSE TO EXIT THE SETUP
SQL BASIC COMMANDS
SELECT
The most commonly-used SQL statement.
Retrieves specific data from a table.
Example: To select the “name” column from a table called “customers”:
SELECT * (SELECT ALL)
Returns all columns in the queried table.
Example: To retrieve all columns from the “customers” table:
SELECT DISTINCT
Returns only distinct (unique) values.
Example: To get unique names from the “customers” table:
SELECT INTO
Copies data from one table to another.
Example: To create a new “customers” table from an existing backup:
SELECT INTO
Copies data from one table to another.
Example: To create a new “customers” table from an existing backup:
SELECT TOP
Returns the top x number or percent of rows from a table.
Example: To get the top 50 results from the “customers” table:
AS (ALIAS)
Renames a column or table with an alias.
Example: To rename the “name” column as “first_name”:
FROM
Specifies the table from which data is pulled.
Example: To select data from the “customers” table:
WHERE
Specifies the table from which data is pulled.
Example: To select data from the “customers” table:
AND
Combines multiple conditions (all must be met).
Example: To get names where both name is ‘Bob’ and age is 55:
OR
Combines multiple conditions (at least one must be met).
Example: To get names where name is ‘Bob’ or age is 55:
BETWEEN
Filters results within a specified range.
Example: To retrieve names where age is between 45 and 55:
LIKE
Searches for a specified pattern in a column.
Example: To find names containing the characters ‘Bob’: