SlideShare a Scribd company logo
SQL Basics
and
DDL statements
Mohd Tousif
2
SQL
Originally 'Sequel' , part of an IBM project in 70's.
SQL is Structured Query Language.
Programming language used for storing and managing data in RDBMS.
All operations performed in Oracle database are run using SQL
statements.
SQL is a declarative (non-procedural language).
Data Types

CHAR (size) : - Stores character strings values of fixed length. The size in the
braces indicates the number of characters the cell can hold. The maximum
number of characters this data type can hold is 255 characters.

VARCHAR(size) / VARCHAR2(size) : - Stores variable length alpha-numeric
data.

DATE : - Used to represent date and time. Standard format is DD-MON -YY.

NUMBER(p,s) : - Stores numbers.

LONG : - Stores variable length character strings. Only one long data can be
defined per table.

RAW / LONG RAW : - Stores binary data, such as digitized picture or image.
Schema & Table
Schema : Collection of logical structures of data or schema objects.
Table : Basic units of data storage in an Oracle database.
SQL Statements
A statement consists of identifiers , parameters , variables, names , data types and
SQL Reserved words.

DDL (Data Definition Language) :- Commands used to create , modify and delete data
structures not data.

DML (Data Manipulation Language) : - Commands used to allow changing data within
the database.

TCL (Transaction Control Language) :- Commands used to control access to data.

DCL (Data Control Language) : - Commands used to control access to database.

DRL (Data Retrieval Language) : - Commands used to get data from the database.
Data Definition Language
DDL statements are dependent upon the structure of the table. All DDL statements
are auto-committed. DDL statements implicitly commit the preceding commands
and start new transactions.

CREATE – Used to create a new database object (Ex: table, index, synonym)

ALTER - Used for modifying the structure of the object.

DROP – Used to remove an object permanently from the database.

TRUNCATE – Used to empty the table.

RENAME – Used to change the name of the table.
CREATE : - Defines each column of the table uniquely. Each column has a
minimum of three attributes : name , data type and size.
CREATE TABLE <Table_Name> (<ColumnName1> <Data Type> (<size>),
<ColumnName2> <Data Type> (<size>),....);
Rules : -
1. A name can have maximum up to 30 characters.
2.Name should begin with alphabet.
3. A-Z , a-z , 0-9 are allowed
4. _ is allowed
5. Reserved words are not allowed
Ex: CREATE TABLE Student
(sid NUMBER(4),student_name VARCHAR2(30),gender CHAR(1));
ALTER :- To modify the structure of a table.
ALTER TABLE <Table_Name> ADD (<New_Column_Name> <Data_Type> (size));
ALTER TABLE <Table_Name> DROP <Column_Name>;
ALTER TABLE <Table_Name> MODIFY (<Column_Name <New_Data_Type>
(size) );
ALTER TABLE <Table_Name> MODIFY (<Column_Name <New_Data_Type>
(new_size) );
ALTER TABLE <Table_Name> MODIFY (<Column_Name <Data_Type>
(new_size) );
ALTER TABLE <Table_Name> RENAME COLUMN <Column_Name> to
<New_Column_Name>;
Rules : -
Cannot decrease the size of a column if table data exists.
Cannot change the data type when data exists.
Examples:
ALTER TABLE student ADD (admission_date DATE,prev_college_name
VARCHAR2(30));
ALTER TABLE student DROP COLUMN prev_college_name;
ALTER TABLE student MODIFY(student_name CHAR(20));
ALTER TABLE student RENAME student_name TO sname;
DROP : - To remove a table permanently from the database
DROP TABLE <Table_Name>;
Example : DROP TABLE student;
TRUNCATE : - Empties a table completely. Structure of the table will be available
for future reference.
TRUNCATE TABLE <Table_Name>;
Example : TRUNCATE TABLE student;
RENAME : - Changes the name of a table permanently.
RENAME <Table_Name> TO <New_Table_Name>;
Example : RENAME Student TO Univ_Student;
Data Manipulation Language
DML statements are used to modify the data available in the table. DML statements
are not auto-committed . The changes made by DML statements are not
permanently stored in the database.

INSERT :- To insert a new row / record into a table

UPDATE :- To modify the existing data in the table.

DELETE :- To remove the data available in the table.

MERGE :- To merge two rows or two tables.
INSERT : - Loads the data into the table
INSERT INTO <Table_Name> VALUES (<expression1>,<expression2>,........);
INSERT INTO <Table_Name> (<Column_Name1>) VALUES (<expression1>);
INSERT INTO <Table_Name> VALUES (<&expr1>,'<&expr2>',........);
INSERT INTO <Table_Name> (<Column_Name1>) VALUES (<&expr1>);
Examples :
INSERT INTO student VALUES (10,'xyz','M','12-oct-95');
INSERT INTO student (sno,sname) VALUES (11,'abc');
INSERT INTO student VALUES (&sno,'&sname','&gender','&doj');
INSERT INTO student (sno,sname) VALUES (&sno,'&sname');
UPDATE : - Changes the data values in a table.
UPDATE <Table_Name> SET <Column_Name>=<Expression1>;
UPDATE <Table_Name> SET <Column_Name>=<Expression1> WHERE <condition>;
Examples :
UPDATE Student SET doj='13-jun-95';
UPDATE Student SET doj='13-jun-95',gender='F' WHERE sid=11;
DELETE : - Deletes rows from a table and returns the number of records deleted.
DELETE FROM <Table_Name>;
DELETE FROM <Table_Name> WHERE <condition>;
Examples :
DELETE FROM student;
DELETE FROM student WHERE sid=11;
18
Data Retrieval Language
SELECT : - To view data from a table.
1.To view all the columns information from a table
SELECT * FROM <Table_Name>;
2. To view all the columns information of a specific column from a table
SELECT <Column_Name> from <Table_Name>;
3. To view all the columns information from a table when a specific condition is
satisfied
SELECT * FROM <Table_Name> WHERE <condition>;
4. To view all the columns information of a specific column from a table when a
specific condition is satisfied
SELECT <Column_Name> from <Table_Name> WHERE
<condition>;
Examples :
SELECT * FROM student;
SELECT sid,sname FROM student;
SELECT * FROM student WHERE sid=1;
SELECT sid,sname FROM student WHERE sid=1;
20
SQL Operators
Operators are symbols which have a special meaning within SQL
and PL/SQL statements.

Arithmetic Operators

Relational Operators

Logical Operators

SET Operators

Range Searching Operators

Pattern Matching Operators

Boolean Operators
21
Oracle allows Arithmetic Operators to be used while viewing records from
a table or while performing data manipulation operations.
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus / Remainder
Example :
SELECT 153*14/15 FROM dual;
SELECT sid,sid+10 FROM student;
Arithmetic Operators
22
The relational operators determines the comparisons within two or more
values.
= Equal
!= Not Equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
Example:
SELECT * FROM student WHERE sid < 20;
SELECT * FROM student WHERE dob != '10-jan-85';
Relational Operators
23
Logical Operators
Operators are used whenever multiple conditions need to be satisfied
AND
OR
NOT
SELECT * FROM student WHERE gender='M' AND dob='15-jan-86';
SELECT * FROM student WHERE gender='M' OR dob='15-jan-86';
24
SET Operators
To retrieve information from multiple tables when there are same
number of columns available in the queries
UNION
UNION ALL
INTERSECT
MINUS
25
Range Searching Operator
To retrieve information within a specified range (including the boundary
values)
BETWEEN
NOT BETWEEN
Example :
SELECT * FROM student WHERE dob BETWEEN '01-jan-85' AND '30-
jun-85';
26
Pattern Matching Operators
LIKE
NOT LIKE
IN
NOT IN
IS NULL
IS NOT NULL
Example:
SELECT * FROM student WHERE sname LIKE '_A%';
SELECT * FROM student WHERE sno IN (15,75,85);
SELECT * FROM student WHERE dob IS NOT NULL;
27
Boolean Operators
EXISTS
NOT EXISTS
ANY
ALL

More Related Content

What's hot (20)

PDF
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
PPT
SQL select clause
arpit bhadoriya
 
PPTX
Sql joins
Gaurav Dhanwant
 
PPT
SQL Queries
Nilt1234
 
PDF
Integrity constraints in dbms
Vignesh Saravanan
 
PPTX
Triggers
Pooja Dixit
 
DOCX
SQL-RDBMS Queries and Question Bank
Md Mudassir
 
PDF
Triggers and Stored Procedures
Tharindu Weerasinghe
 
PPTX
DBMS Notes: DDL DML DCL
Sreedhar Chowdam
 
PPTX
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
PPTX
SQL
Vineeta Garg
 
PPT
Advance Database Management Systems -Object Oriented Principles In Database
Sonali Parab
 
PPT
Introduction to structured query language (sql)
Sabana Maharjan
 
PPTX
Aggregate function
Rayhan Chowdhury
 
PPT
Including Constraints -Oracle Data base
Salman Memon
 
PPTX
Oracle: Joins
oracle content
 
PPT
Data independence
Aashima Wadhwa
 
PPTX
SQL Functions
ammarbrohi
 
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
SQL select clause
arpit bhadoriya
 
Sql joins
Gaurav Dhanwant
 
SQL Queries
Nilt1234
 
Integrity constraints in dbms
Vignesh Saravanan
 
Triggers
Pooja Dixit
 
SQL-RDBMS Queries and Question Bank
Md Mudassir
 
Triggers and Stored Procedures
Tharindu Weerasinghe
 
DBMS Notes: DDL DML DCL
Sreedhar Chowdam
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
Advance Database Management Systems -Object Oriented Principles In Database
Sonali Parab
 
Introduction to structured query language (sql)
Sabana Maharjan
 
Aggregate function
Rayhan Chowdhury
 
Including Constraints -Oracle Data base
Salman Memon
 
Oracle: Joins
oracle content
 
Data independence
Aashima Wadhwa
 
SQL Functions
ammarbrohi
 

Similar to Sql basics and DDL statements (20)

PPTX
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
sdnsdf
 
PPTX
SQL Query
Imam340267
 
PPT
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
PDF
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
PPTX
SQL: Data Definition Language(DDL) command
sonali sonavane
 
PPTX
SQL - DML and DDL Commands
Shrija Madhu
 
PPTX
SQL commands powerpoint presentation. Ppt
umadevikakarlapudi
 
PPTX
Database models and DBMS languages
DivyaKS12
 
PPTX
SQL
Shyam Khant
 
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
PDF
Sql smart reference_by_prasad
paddu123
 
PDF
Sql smart reference_by_prasad
paddu123
 
PDF
Introduction to SQL..pdf
mayurisonawane29
 
DOCX
Database Management Lab -SQL Queries
shamim hossain
 
DOCX
COMPUTERS SQL
Rc Os
 
PPTX
SQL | DML
To Sum It Up
 
PPTX
lovely
love0323
 
PPT
SQL. It education ppt for reference sql process coding
aditipandey498628
 
PPTX
DBMS: Week 05 - Introduction to SQL Query
RashidFaridChishti
 
PDF
Sql tutorial
amitabros
 
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
sdnsdf
 
SQL Query
Imam340267
 
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
SQL: Data Definition Language(DDL) command
sonali sonavane
 
SQL - DML and DDL Commands
Shrija Madhu
 
SQL commands powerpoint presentation. Ppt
umadevikakarlapudi
 
Database models and DBMS languages
DivyaKS12
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Sql smart reference_by_prasad
paddu123
 
Sql smart reference_by_prasad
paddu123
 
Introduction to SQL..pdf
mayurisonawane29
 
Database Management Lab -SQL Queries
shamim hossain
 
COMPUTERS SQL
Rc Os
 
SQL | DML
To Sum It Up
 
lovely
love0323
 
SQL. It education ppt for reference sql process coding
aditipandey498628
 
DBMS: Week 05 - Introduction to SQL Query
RashidFaridChishti
 
Sql tutorial
amitabros
 
Ad

More from Mohd Tousif (20)

PDF
Sql commands
Mohd Tousif
 
PDF
SQL practice questions set
Mohd Tousif
 
PPT
Introduction to Databases
Mohd Tousif
 
PPS
Entity Relationship Model - An Example
Mohd Tousif
 
PDF
Entity Relationship (ER) Model Questions
Mohd Tousif
 
PPTX
Entity Relationship (ER) Model
Mohd Tousif
 
PDF
SQL Practice Question set
Mohd Tousif
 
PDF
Introduction to Databases - Assignment_1
Mohd Tousif
 
PDF
Data Definition Language (DDL)
Mohd Tousif
 
PDF
Data Warehouse Concepts and Architecture
Mohd Tousif
 
DOC
SQL practice questions set - 2
Mohd Tousif
 
DOC
SQL practice questions - set 3
Mohd Tousif
 
DOC
SQL practice questions for beginners
Mohd Tousif
 
PDF
Oracle sql tutorial
Mohd Tousif
 
PDF
Sql (Introduction to Structured Query language)
Mohd Tousif
 
PDF
Sql commands
Mohd Tousif
 
PDF
Virtual box
Mohd Tousif
 
PDF
Deadlock
Mohd Tousif
 
PDF
Algorithm o.s.
Mohd Tousif
 
PPTX
System components of windows xp
Mohd Tousif
 
Sql commands
Mohd Tousif
 
SQL practice questions set
Mohd Tousif
 
Introduction to Databases
Mohd Tousif
 
Entity Relationship Model - An Example
Mohd Tousif
 
Entity Relationship (ER) Model Questions
Mohd Tousif
 
Entity Relationship (ER) Model
Mohd Tousif
 
SQL Practice Question set
Mohd Tousif
 
Introduction to Databases - Assignment_1
Mohd Tousif
 
Data Definition Language (DDL)
Mohd Tousif
 
Data Warehouse Concepts and Architecture
Mohd Tousif
 
SQL practice questions set - 2
Mohd Tousif
 
SQL practice questions - set 3
Mohd Tousif
 
SQL practice questions for beginners
Mohd Tousif
 
Oracle sql tutorial
Mohd Tousif
 
Sql (Introduction to Structured Query language)
Mohd Tousif
 
Sql commands
Mohd Tousif
 
Virtual box
Mohd Tousif
 
Deadlock
Mohd Tousif
 
Algorithm o.s.
Mohd Tousif
 
System components of windows xp
Mohd Tousif
 
Ad

Recently uploaded (20)

PPTX
SHREYAS25 INTERN-I,II,III PPT (1).pptx pre
swapnilherage
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PPTX
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PPTX
BinarySearchTree in datastructures in detail
kichokuttu
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PDF
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PDF
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PPTX
Powerful Uses of Data Analytics You Should Know
subhashenia
 
PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
PDF
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
PPTX
03_Ariane BERCKMOES_Ethias.pptx_AIBarometer_release_event
FinTech Belgium
 
SHREYAS25 INTERN-I,II,III PPT (1).pptx pre
swapnilherage
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
BinarySearchTree in datastructures in detail
kichokuttu
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
Powerful Uses of Data Analytics You Should Know
subhashenia
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
03_Ariane BERCKMOES_Ethias.pptx_AIBarometer_release_event
FinTech Belgium
 

Sql basics and DDL statements

  • 2. 2 SQL Originally 'Sequel' , part of an IBM project in 70's. SQL is Structured Query Language. Programming language used for storing and managing data in RDBMS. All operations performed in Oracle database are run using SQL statements. SQL is a declarative (non-procedural language).
  • 3. Data Types  CHAR (size) : - Stores character strings values of fixed length. The size in the braces indicates the number of characters the cell can hold. The maximum number of characters this data type can hold is 255 characters.  VARCHAR(size) / VARCHAR2(size) : - Stores variable length alpha-numeric data.  DATE : - Used to represent date and time. Standard format is DD-MON -YY.  NUMBER(p,s) : - Stores numbers.  LONG : - Stores variable length character strings. Only one long data can be defined per table.  RAW / LONG RAW : - Stores binary data, such as digitized picture or image.
  • 4. Schema & Table Schema : Collection of logical structures of data or schema objects. Table : Basic units of data storage in an Oracle database.
  • 5. SQL Statements A statement consists of identifiers , parameters , variables, names , data types and SQL Reserved words.  DDL (Data Definition Language) :- Commands used to create , modify and delete data structures not data.  DML (Data Manipulation Language) : - Commands used to allow changing data within the database.  TCL (Transaction Control Language) :- Commands used to control access to data.  DCL (Data Control Language) : - Commands used to control access to database.  DRL (Data Retrieval Language) : - Commands used to get data from the database.
  • 6. Data Definition Language DDL statements are dependent upon the structure of the table. All DDL statements are auto-committed. DDL statements implicitly commit the preceding commands and start new transactions.  CREATE – Used to create a new database object (Ex: table, index, synonym)  ALTER - Used for modifying the structure of the object.  DROP – Used to remove an object permanently from the database.  TRUNCATE – Used to empty the table.  RENAME – Used to change the name of the table.
  • 7. CREATE : - Defines each column of the table uniquely. Each column has a minimum of three attributes : name , data type and size. CREATE TABLE <Table_Name> (<ColumnName1> <Data Type> (<size>), <ColumnName2> <Data Type> (<size>),....); Rules : - 1. A name can have maximum up to 30 characters. 2.Name should begin with alphabet. 3. A-Z , a-z , 0-9 are allowed 4. _ is allowed 5. Reserved words are not allowed Ex: CREATE TABLE Student (sid NUMBER(4),student_name VARCHAR2(30),gender CHAR(1));
  • 8. ALTER :- To modify the structure of a table. ALTER TABLE <Table_Name> ADD (<New_Column_Name> <Data_Type> (size)); ALTER TABLE <Table_Name> DROP <Column_Name>; ALTER TABLE <Table_Name> MODIFY (<Column_Name <New_Data_Type> (size) ); ALTER TABLE <Table_Name> MODIFY (<Column_Name <New_Data_Type> (new_size) ); ALTER TABLE <Table_Name> MODIFY (<Column_Name <Data_Type> (new_size) ); ALTER TABLE <Table_Name> RENAME COLUMN <Column_Name> to <New_Column_Name>; Rules : - Cannot decrease the size of a column if table data exists. Cannot change the data type when data exists.
  • 9. Examples: ALTER TABLE student ADD (admission_date DATE,prev_college_name VARCHAR2(30)); ALTER TABLE student DROP COLUMN prev_college_name; ALTER TABLE student MODIFY(student_name CHAR(20)); ALTER TABLE student RENAME student_name TO sname;
  • 10. DROP : - To remove a table permanently from the database DROP TABLE <Table_Name>; Example : DROP TABLE student;
  • 11. TRUNCATE : - Empties a table completely. Structure of the table will be available for future reference. TRUNCATE TABLE <Table_Name>; Example : TRUNCATE TABLE student;
  • 12. RENAME : - Changes the name of a table permanently. RENAME <Table_Name> TO <New_Table_Name>; Example : RENAME Student TO Univ_Student;
  • 13. Data Manipulation Language DML statements are used to modify the data available in the table. DML statements are not auto-committed . The changes made by DML statements are not permanently stored in the database.  INSERT :- To insert a new row / record into a table  UPDATE :- To modify the existing data in the table.  DELETE :- To remove the data available in the table.  MERGE :- To merge two rows or two tables.
  • 14. INSERT : - Loads the data into the table INSERT INTO <Table_Name> VALUES (<expression1>,<expression2>,........); INSERT INTO <Table_Name> (<Column_Name1>) VALUES (<expression1>); INSERT INTO <Table_Name> VALUES (<&expr1>,'<&expr2>',........); INSERT INTO <Table_Name> (<Column_Name1>) VALUES (<&expr1>);
  • 15. Examples : INSERT INTO student VALUES (10,'xyz','M','12-oct-95'); INSERT INTO student (sno,sname) VALUES (11,'abc'); INSERT INTO student VALUES (&sno,'&sname','&gender','&doj'); INSERT INTO student (sno,sname) VALUES (&sno,'&sname');
  • 16. UPDATE : - Changes the data values in a table. UPDATE <Table_Name> SET <Column_Name>=<Expression1>; UPDATE <Table_Name> SET <Column_Name>=<Expression1> WHERE <condition>; Examples : UPDATE Student SET doj='13-jun-95'; UPDATE Student SET doj='13-jun-95',gender='F' WHERE sid=11;
  • 17. DELETE : - Deletes rows from a table and returns the number of records deleted. DELETE FROM <Table_Name>; DELETE FROM <Table_Name> WHERE <condition>; Examples : DELETE FROM student; DELETE FROM student WHERE sid=11;
  • 18. 18 Data Retrieval Language SELECT : - To view data from a table. 1.To view all the columns information from a table SELECT * FROM <Table_Name>; 2. To view all the columns information of a specific column from a table SELECT <Column_Name> from <Table_Name>; 3. To view all the columns information from a table when a specific condition is satisfied SELECT * FROM <Table_Name> WHERE <condition>; 4. To view all the columns information of a specific column from a table when a specific condition is satisfied SELECT <Column_Name> from <Table_Name> WHERE <condition>;
  • 19. Examples : SELECT * FROM student; SELECT sid,sname FROM student; SELECT * FROM student WHERE sid=1; SELECT sid,sname FROM student WHERE sid=1;
  • 20. 20 SQL Operators Operators are symbols which have a special meaning within SQL and PL/SQL statements.  Arithmetic Operators  Relational Operators  Logical Operators  SET Operators  Range Searching Operators  Pattern Matching Operators  Boolean Operators
  • 21. 21 Oracle allows Arithmetic Operators to be used while viewing records from a table or while performing data manipulation operations. + Addition - Subtraction * Multiplication / Division % Modulus / Remainder Example : SELECT 153*14/15 FROM dual; SELECT sid,sid+10 FROM student; Arithmetic Operators
  • 22. 22 The relational operators determines the comparisons within two or more values. = Equal != Not Equal > Greater than < Less than >= Greater than or equal <= Less than or equal Example: SELECT * FROM student WHERE sid < 20; SELECT * FROM student WHERE dob != '10-jan-85'; Relational Operators
  • 23. 23 Logical Operators Operators are used whenever multiple conditions need to be satisfied AND OR NOT SELECT * FROM student WHERE gender='M' AND dob='15-jan-86'; SELECT * FROM student WHERE gender='M' OR dob='15-jan-86';
  • 24. 24 SET Operators To retrieve information from multiple tables when there are same number of columns available in the queries UNION UNION ALL INTERSECT MINUS
  • 25. 25 Range Searching Operator To retrieve information within a specified range (including the boundary values) BETWEEN NOT BETWEEN Example : SELECT * FROM student WHERE dob BETWEEN '01-jan-85' AND '30- jun-85';
  • 26. 26 Pattern Matching Operators LIKE NOT LIKE IN NOT IN IS NULL IS NOT NULL Example: SELECT * FROM student WHERE sname LIKE '_A%'; SELECT * FROM student WHERE sno IN (15,75,85); SELECT * FROM student WHERE dob IS NOT NULL;