0% found this document useful (0 votes)
3 views12 pages

Introduction to SQL Basics and Queries

The document provides an overview of SQL (Structured Query Language), including its history, statements, conventions, and operators. It outlines the different categories of SQL statements such as DDL, DML, and TCL, and explains how SQL queries function. Additionally, it includes practical examples and exercises for users to practice SQL queries.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Introduction to SQL Basics and Queries

The document provides an overview of SQL (Structured Query Language), including its history, statements, conventions, and operators. It outlines the different categories of SQL statements such as DDL, DML, and TCL, and explains how SQL queries function. Additionally, it includes practical examples and exercises for users to practice SQL queries.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

SQL – Structured Query

Language
1

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
2 Lecture Outline
 Introduction to SQL
 History of SQL
 SQL Statements
 SQL Conventions
 SQL Queries
 Installation of Oracle 10g (Pracitical)

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
3 Introduction to SQL
 SQL: Structured Query Language
 Pronounced “S-Q-L” by some and “Sequel” by others.
 SQL is not a complete programming language; rather, it is
a data sublanguage.
 SQL consists only of constructs for defining and
processing a database.
 SQL can be embedded in other programming languages
such as Java, VB, C# etc.

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
4 History of SQL
 SQL was developed by the IBM Corporation in the late 1970s,
and successive versions were endorsed as national standards by
the American National Standards Institute (ANSI) in 1986, 1989,
and 1992.
 In 1999, SQL:1999 (also referred to as SQL3), which incorporated
some object-oriented concepts, was released.
 This was followed by the release of SQL:2003 in 2003, SQL:2006
in 2006, SQL:2008 in 2008, and, most recently, SQL:2011 in 2011.
 Each of these added new features or extended existing SQL
features, including SQL support for Extensible Markup Language
(XML), “Big Data,” and, in SQL:2008, the SQL TRUNCATE TABLE
and SQL MERGE statements.
 SQL has also been endorsed as a standard by the International
Organization for Standardization (ISO).

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
5 SQL
 SQL is text-oriented.
 It was developed long before the graphical user interface
(GUI) became common and requires only a text processor.
 Products that provide GUI interface to perform many of
SQL tasks are:
 Microsoft Access,
 Microsoft SQL Server,
 Oracle Database,
 MySQL, and other DBMSs.

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
6 SQL Statements
SQL statements are commonly divided into categories including:
 Data Definition Language (DDL)
 Statements, which are used for creating tables, relationships, and other
structures.
 Data Manipulation Language (DML)
 Statements, which are used for querying, inserting, modifying, and deleting data.
 SQL/Persistent Stored Modules (SQL/PSM)
 Statements, which extend SQL by adding procedural programming capabilities,
such as variables and flow-of-control statements, that provide some
programmability within the SQL framework.
 Transaction Control Language (TCL)
 Statements, which are used to mark transaction boundaries and control
transaction behavior.
 Data Control Language (DCL)
 Statements, which are used to grant/revoke database permissions to users and
groups.
Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
7 SQL Conventions
 SQL commands are case insensitive
 SELECT = Select = select
 Values are case sensitive
 “Afghan” ≠ “afghan”
 Each statement in SQL ends with a Semicolon;
 Queries can be broken down into several lines for better
understandings.
 In that case only the last statement should contain a
semicolon.

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
8 Operators used in SQL
 Relational Operators
< , > , <= , >= , = , <>
 Logical Operators
AND, OR and NOT
 Arithmetic Operators
+, -, *, /
Other Operators are: IS, IS NOT, LIKE, BETWEEN,
NOT BETWEEN, IN, NOT IN etc.

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
9 How SQL Engine Works?
 SQL = WHAT we want = declarative
 Relational algebra = HOW to get it = algorithm
 RDBMS are about translating WHAT to HOW
 Job done by Query optimizer

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
10 SQL Queries
 A query is a question you ask the database.
 If any of the data in the database satisfes the conditions of your
query, SQL retrieves that data.
 Example: To retrieve the data of employees who are 40 years old
or above or those whose salary is greater than 100000, the SQL
query can be written as:
 SELECT * FROM EMPLOYEE WHERE Age > 40 OR Salary > 100000 ;
 SELECT is a keyword used to select records from a table.
 * Means all records existing in a table
 FROM is a keyword used to specify a table from which data is
retrieved
 WHERE is a keyword used to specify a certain condition and to limit
the search criteria.

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
11 Now Practice The Following
Queries
 SQL> cle scr;  SQL> select empno,ename,job from emp;
 SQL> clear screen;  SQL> select ename,empno,job from emp;

 SQL> show user;  SQL> select 1,2 from emp;

 SQL> select * from  SQL> select empno,ename as name from


emp;
cat;
 SQL> select empno,ename as Std Name from
 SQL> desc dept;
emp;
 SQL> desc emp;  SQL> select empno,ename as “Std Name”
 SQL> select * from from emp;
emp;  SQL> select empno,ename as “Name” from
emp;

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24
12

Thank You!

Instructor: Najib Ullah Sadaat | Email: [Link]@[Link] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24
| Oct, 19, 2019
90 24

You might also like