This document provides an overview of structured query language (SQL) including:
- SQL is used to store, manipulate and retrieve data from relational databases.
- It allows users to access, describe, define, embed, create, drop, and set permissions on database objects.
- When executing SQL commands, a query dispatcher and optimization engines determine the best way to carry out the request by figuring out how to interpret the task.
- SQL defines constraints like NOT NULL, DEFAULT, UNIQUE, PRIMARY KEY, FOREIGN KEY, and CHECK to maintain data integrity.
- It supports various data types including character, numeric, date/time, large object, and rowid data types.
- SQL statements are
1. LECTURE -2
S T R U C T U R E D Q U E R Y L A N G U A G E
( B A S I C S )
D e l i v e r e d B y :
M r . S h u b h a m S h u k l a
2. WHAT IS SQL?
SQL is Structured Query Language, which is a computer language for storing,
manipulating and retrieving data stored in a relational database.
Why SQL?
SQL is widely popular because it offers the following advantages:
• Allows users to access data in the relational database management systems.
• Allows users to describe the data.
• Allows users to define the data in a database and manipulate that data.
• Allows to embed within other languages using SQL modules, libraries & pre-
compilers.
• Allows users to create and drop databases and tables.
• Allows users to create view, stored procedure, functions in a database.
• Allows users to set permissions on tables, procedures and views.
3. SQL Process
• When you are executing an SQL command for any RDBMS, the system
determines the best way to carry out your request and SQL engine figures out
how to interpret the task. There are various components included in this
process.
These components are –
Query Dispatcher
Optimization Engines
Classic Query Engine
SQL Query Engine, etc.
• A classic query engine handles all the non-SQL queries, but a SQL query
engine won't handle logical files.
5. SQL CONSTRAINTS
• NOT NULL Constraint: Ensures that a column cannot have a NULL value.
• DEFAULT Constraint: Provides a default value for a column when none is
specified.
• UNIQUE Constraint: Ensures that all the values in a column are different.
• PRIMARY Key: Uniquely identifies each row/record in a database table.
• FOREIGN Key: Uniquely identifies a row/record in any another database
table.
• CHECK Constraint: The CHECK constraint ensures that all values in a
column satisfy certain conditions.
• INDEX: Used to create and retrieve data from the database very quickly.
6. DATA INTEGRITY
• The following categories of data integrity exist with each RDBMS:
Entity Integrity: There are no duplicate rows in a table.
Domain Integrity: Enforces valid entries for a given column by
restricting the type, the format, or the range of values.
Referential integrity: Rows cannot be deleted, which are used by other
records.
User-Defined Integrity: Enforces some specific business rules that do
not fall into entity, domain or referential integrity.
7. SQL - DATA TYPES
Character Datatypes:
The following are the Character Datatypes in Oracle/PLSQL:
13. • Data Definition Language (DDL):
– Commands that define a database - Create, Alter, Drop
• Data Manipulation Language (DML)
– Commands that maintain and query a database.
• Data Control Language (DCL)
– Commands that control a database, including administering privileges and
committing data.
TYPES OF SQL COMMANDS: