0% found this document useful (0 votes)
108 views25 pages

Introduction To SQL: University of Tehran NOVEMBER, 2016

This document provides an introduction to SQL (Structured Query Language). It defines SQL as the standard language for managing relational database systems and describes the main SQL commands: DDL for data definition, DML for data manipulation, DCL for data control, and DQL for data queries. It also outlines key concepts like database tables, records, fields, and constraints. The document provides examples of SQL statements for tasks like creating users and tables, inserting/updating/deleting data, and performing queries with filters, sorts, groups, and joins.

Uploaded by

Alvin Enrico
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views25 pages

Introduction To SQL: University of Tehran NOVEMBER, 2016

This document provides an introduction to SQL (Structured Query Language). It defines SQL as the standard language for managing relational database systems and describes the main SQL commands: DDL for data definition, DML for data manipulation, DCL for data control, and DQL for data queries. It also outlines key concepts like database tables, records, fields, and constraints. The document provides examples of SQL statements for tasks like creating users and tables, inserting/updating/deleting data, and performing queries with filters, sorts, groups, and joins.

Uploaded by

Alvin Enrico
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Introduction to

SQL
UNIVERSITY OF TEHRAN
NOVEMBER, 2016
What is SQL?

 Structured Query Language


 SQL is Structured Query Language, which is a
computer language for storing, manipulating and
retrieving data stored in relational database.

 SQL is the standard language for Relation Database


System. All relational database management systems
like “MySQL, MS Access, Oracle, Sybase, Informix,
postgres and SQL Server” use SQL as standard
database language.
SQL Commands

 DDL - Data Definition Language

 DML - Data Manipulation Language

 DCL - Data Control Language

 DQL - Data Query Language


SQL Commands
SQL Commands
SQL RDBMS Concepts

 TABLE
 RECORD
 COLUMN
 CELL

 NULL?
SQL RDBMS Concepts
 SQL Constraints: (applied on columns)
 NOT NULL Constraint
 UNIQUE Constraint
 PRIMARY Key
 FOREIGN Key
 CHECK Constraint
 Data Integrity:
 Entity Integrity: There are no duplicate rows in a table
 Domain Integrity: Enforces valid entries for a given column by
restricting the type
 Referential Integrity: Rows cannot be deleted which are used by
other records
 User-Defined Integrity: Enforces some specific business rules
SQL RDBMS Concepts
 Data Types:
 Character datatypes:
 CHAR
 NCHAR
 NVARCHAR2
 VARCHAR2
 Numeric datatypes:
 NUMBER
 BINARY_FLOAT
 BINARY_DOUBLE
 Date time datatype:
 DATE
DCL: CREATE USER

 1) Define User with Username/Password


 2) Grants Sufficient Privileges.

 Using SQL Developer (UI, Command)


 Using SQL *PLUS (Command)
SQL : DDL
 Create Table:
 COLUMNS
 CONSTRAINTS
SQL: DDL

 DROP TABLE:

 ALTER TABLE

 OTHER DDL COMMANDS!!!!


SQL: DML: INSERT
 INSERT INTO:
 NUMBER, CHAR/VARCHAR2, DATE?
SQL: DML: INSERT
 INSERT INTO:
 SPECIFIC COLUMNS
SQL: DML: INSERT
 INSERT INTO:
 FOREIGN KEY

 ALL DML COMMANDS NEED COMMIT


SQL: DML: UPDATE
 UPDATE

 WHERE CLAUSE
SQL: DML: DELETE
 DELETE (DELETE VS DROP????)
HR-Schema
SQL: DQL: SELECT
 SELECT
 *

 SPECIFIC COLUMNS
SQL: DQL: SELECT
 DISTINCT CLUASE
SQL: DQL: SELECT
 WHERE CLUASE
SQL: DQL: SELECT
 IN CLUASE
 NOT IN

 NULL IN WHERE?
 IS NULL
 IS NOT NULL
SQL: DQL: SELECT
 ORDER BY
SQL: DQL: SELECT
 GROUP BY

 AGGREGATE FUCTION
 MAX,MIN
 AVG
 COUNT
 SUM
 …
 HAVING CLAUSE
SQL: DQL: SELECT
 SELECT FROM MULTIPLE TABLES
 CARTESIAN MULTIPICATION

 JOIN
About Me

 Ehsan Hamzei
 Graduate Student of Geospatial Information System
 University of Tehran
 Git-Hub: https://github.com/ehsan-hamzei/

 Source-Codes: https://github.com/ehsan-
hamzei/Oracle-SQL/

You might also like