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

Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
Ishucs
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
VARSHAKUMARI49
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
rainynovember12
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Sachidananda M H
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
BG Java EE Course
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
Hammad Rasheed
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | Edureka
Edureka!
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
Ahmed Farag
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
Aditya Kumar Tripathy
 
Structured Query Language
Structured Query LanguageStructured Query Language
Structured Query Language
Surkhab Shelly
 
Join query
Join queryJoin query
Join query
Waqar Ali
 

What's hot (20)

Sql commands
Sql commandsSql commands
Sql commands
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Mysql
MysqlMysql
Mysql
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | Edureka
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Structured Query Language
Structured Query LanguageStructured Query Language
Structured Query Language
 
Join query
Join queryJoin query
Join query
 

Similar to Sql basics and DDL statements

SQL Query
SQL QuerySQL Query
SQL Query
Imam340267
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
DivyaKS12
 
SQL
SQLSQL
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
mayurisonawane29
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
shamim hossain
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
Rc Os
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
To Sum It Up
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
amitabros
 
Lab
LabLab
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
PriyaPandey767008
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
Balqees Al.Mubarak
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
MUHAMMADANSAR76
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
Abrar ali
 
Module 3
Module 3Module 3
Module 3
cs19club
 

Similar to Sql basics and DDL statements (20)

SQL Query
SQL QuerySQL Query
SQL Query
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
 
SQL
SQLSQL
SQL
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
lovely
lovelylovely
lovely
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Lab
LabLab
Lab
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Module 3
Module 3Module 3
Module 3
 

More from Mohd Tousif

Sql commands
Sql commandsSql commands
Sql commands
Mohd Tousif
 
SQL practice questions set
SQL practice questions setSQL practice questions set
SQL practice questions set
Mohd Tousif
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
Mohd Tousif
 
Entity Relationship Model - An Example
Entity Relationship Model - An ExampleEntity Relationship Model - An Example
Entity Relationship Model - An Example
Mohd Tousif
 
Entity Relationship (ER) Model Questions
Entity Relationship (ER) Model QuestionsEntity Relationship (ER) Model Questions
Entity Relationship (ER) Model Questions
Mohd Tousif
 
Entity Relationship (ER) Model
Entity Relationship (ER) ModelEntity Relationship (ER) Model
Entity Relationship (ER) Model
Mohd Tousif
 
SQL Practice Question set
SQL Practice Question set SQL Practice Question set
SQL Practice Question set
Mohd Tousif
 
Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1
Mohd Tousif
 
Data Definition Language (DDL)
Data Definition Language (DDL) Data Definition Language (DDL)
Data Definition Language (DDL)
Mohd Tousif
 
Data Warehouse Concepts and Architecture
Data Warehouse Concepts and ArchitectureData Warehouse Concepts and Architecture
Data Warehouse Concepts and Architecture
Mohd Tousif
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2
Mohd Tousif
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3
Mohd Tousif
 
SQL practice questions for beginners
SQL practice questions for beginnersSQL practice questions for beginners
SQL practice questions for beginners
Mohd Tousif
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
Mohd Tousif
 
Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)
Mohd Tousif
 
Sql commands
Sql commandsSql commands
Sql commands
Mohd Tousif
 
Virtual box
Virtual boxVirtual box
Virtual box
Mohd Tousif
 
System components of windows xp
System components of windows xpSystem components of windows xp
System components of windows xpMohd Tousif
 

More from Mohd Tousif (20)

Sql commands
Sql commandsSql commands
Sql commands
 
SQL practice questions set
SQL practice questions setSQL practice questions set
SQL practice questions set
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
 
Entity Relationship Model - An Example
Entity Relationship Model - An ExampleEntity Relationship Model - An Example
Entity Relationship Model - An Example
 
Entity Relationship (ER) Model Questions
Entity Relationship (ER) Model QuestionsEntity Relationship (ER) Model Questions
Entity Relationship (ER) Model Questions
 
Entity Relationship (ER) Model
Entity Relationship (ER) ModelEntity Relationship (ER) Model
Entity Relationship (ER) Model
 
SQL Practice Question set
SQL Practice Question set SQL Practice Question set
SQL Practice Question set
 
Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1
 
Data Definition Language (DDL)
Data Definition Language (DDL) Data Definition Language (DDL)
Data Definition Language (DDL)
 
Data Warehouse Concepts and Architecture
Data Warehouse Concepts and ArchitectureData Warehouse Concepts and Architecture
Data Warehouse Concepts and Architecture
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3
 
SQL practice questions for beginners
SQL practice questions for beginnersSQL practice questions for beginners
SQL practice questions for beginners
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)
 
Sql commands
Sql commandsSql commands
Sql commands
 
Virtual box
Virtual boxVirtual box
Virtual box
 
Deadlock
DeadlockDeadlock
Deadlock
 
Algorithm o.s.
Algorithm o.s.Algorithm o.s.
Algorithm o.s.
 
System components of windows xp
System components of windows xpSystem components of windows xp
System components of windows xp
 

Recently uploaded

一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Boston Institute of Analytics
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
pchutichetpong
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
NABLAS株式会社
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
u86oixdj
 

Recently uploaded (20)

一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
 

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;