SlideShare a Scribd company logo
1 of 16
Download to read offline
SQL Fundamentals
SQL: Structured Query Language is a simple and powerful
language used to create, access, and manipulate data and structure
in the database. SQL is like plain English: easy to understand and to
write. SQL statements into various categories, which are:
•Data Definition Language
•Data Manipulation Language
•Data Control Language.
•Transaction Control Language
•Embedded SQL statements
Data Definition Language (DDL) statements:
Thapar University, Oracle Short Term Course
DDL statements are used to define, alter, or drop database objects.
The following table gives an overview about usage of DDL
statements in ORACLE (a commercially used database):
Data Manipulation Language
(DML) statements
Once the tables have been created, the DML statements enable
users to query or manipulate data in existing schemas objects.
DML statements are normally the most frequently used
commands.
The following table gives an overview about the usage of DML
statements in ORACLE.
Thapar University, Oracle Short Term Course
Data Control Language (DCL)
A privilege can either be granted to a User with the help of
GRANT statement. The privileges assigned can be SELECT,
ALTER, DELETE, EXECUTE, INSERT, INDEX etc. In addition
to granting of privileges, you can also revoke it by using
REVOKE command.
Transaction Control Statements (TCL) statements:
Thapar University, Oracle Short Term Course
TCL statements manage the change made by DML statements, and
group DML statements into transactions. The following table gives
an overview about the usage of TCL statements in ORACLE.
Embedded SQL statements
Thapar University, Oracle Short Term Course
The SQL statements used to incorporate DDL,DML and transaction
control statements within the body of a procedural language
program, are known as Embedded SQL statements. The following
table gives an overview about the usage of Embedded SQL
statements in ORACLE.
Oracle Data types
The information in a database is maintained in the
form of tables and each table consists of rows and
columns, which store data, and therefore this data
must have some data type i.e the type of data,
which is stored in a table.
Data types
The most commonly used data
types
 char
 varchar or varchar2
 number
 date
 long
 long raw/ raw
Let us now briefly describe these data types:
Char(n)
This data type is used to store character strings of fixed size. The size
of the character string is determined by the numeric value of n. This
data type can hold maximum of 255 characters.
When Oracle stores data in a CHAR data type, it will pad the value
stored in the column up to the length of the column as declared by the
table with blanks.
For example: If data type of address field is mentioned as CHAR(40)
and address information of a particular record complete in 20
characters, then remaining 20 characters space is padded with blank
characters.
Varchar(n) / Varchar2(n)
This data type is used to store variable length alphanumeric data. It can
store maximum of 2000 characters. In case of varchar data type, Oracle
will not store padded blank spaces if the value stored in a column
defined is less than length of the column as declared by the table with
data type VARCHAR2.
For example: If data type of address field is mentioned as
VARCHAR(40) and address information of a particular record complete
in 20 characters, then remaining 20 characters space is not padded with
blank characters and memory space of 20 characters is used for some
other purposes and not wasted as padded with blank characters.
Number (p,s)
This data type is used to store numbers fixed or floating point .
The precision (p) determines the length of the data while (s), the scale,
determines the number of places after the decimal.
The NUMBER data type that is used to store number data can be
specified either to store integers or decimals with the addition of a
parenthetical precision indicator.
For example, if you had a column defined to be data type
NUMBER(10,3), the number 546.3832 would be stored as 546.383,
because after the decimal point we can store 3 digits. It can store a
number of 10 digits including a decimal point for example a maximum
number of 999999.999 can be stored with data type of
NUMBER(10,3).
Date
This data type, stores date values in a special format internal to
Oracle.
It offers a great deal of flexibility to users who want to perform
date manipulation operations There are also numerous functions
that handle date operations more complex than simple
arithmetic.
The default format in which date is stored is DD-MON-YY. If
we want to store date in other format then we have to use the
appropriate functions.
Long
The developer can declare columns to be of LONG data type, which
can stores upto 2 gigabytes of alphanumeric text data. The values of
long data type cannot be indexed and normal characters functions such
as SUBSTR cannot be applied to long values.
Long Raw / Raw
It is useful to store graphics and sound files when used in conjunction
with LONG to form the LONG RAW data type, which can
accommodate up to 2 gigabytes of data.
Note: A table cannot contain more than one Long column. They cannot
be indexed and no integrity constraints can be applied on them (except
for NULL and NOT NULL constrain).
Simplified Approach To Oracle
By
Parteek Bhatia

More Related Content

What's hot (20)

introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Linked List
Linked ListLinked List
Linked List
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
Relational model
Relational modelRelational model
Relational model
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | Edureka
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQL
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Indexing and Hashing
Indexing and HashingIndexing and Hashing
Indexing and Hashing
 

Similar to Sql fundamentals

Similar to Sql fundamentals (20)

Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
 
Oracle
OracleOracle
Oracle
 
Dbms Basics
Dbms BasicsDbms Basics
Dbms Basics
 
12 SQL
12 SQL12 SQL
12 SQL
 
12 SQL
12 SQL12 SQL
12 SQL
 
chapter-14-sql-commands.pdf
chapter-14-sql-commands.pdfchapter-14-sql-commands.pdf
chapter-14-sql-commands.pdf
 
Sql server lesson5
Sql server lesson5Sql server lesson5
Sql server lesson5
 
Ankit
AnkitAnkit
Ankit
 
Sql Server Interview Question
Sql Server Interview QuestionSql Server Interview Question
Sql Server Interview Question
 
SQL ppt.pptx
SQL ppt.pptxSQL ppt.pptx
SQL ppt.pptx
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
 
Sql commands
Sql commandsSql commands
Sql commands
 
Presentation1
Presentation1Presentation1
Presentation1
 
Anchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data typeAnchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data type
 
R Text-Based Data I/O and Data Frame Access and Manupulation
R Text-Based Data I/O and Data Frame Access and ManupulationR Text-Based Data I/O and Data Frame Access and Manupulation
R Text-Based Data I/O and Data Frame Access and Manupulation
 
SQL, Oracle, Joins
SQL, Oracle, JoinsSQL, Oracle, Joins
SQL, Oracle, Joins
 

More from Ravinder Kamboj

More from Ravinder Kamboj (14)

Data warehouse,data mining & Big Data
Data warehouse,data mining & Big DataData warehouse,data mining & Big Data
Data warehouse,data mining & Big Data
 
DDBMS
DDBMSDDBMS
DDBMS
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Query processing
Query processingQuery processing
Query processing
 
Normalization of Data Base
Normalization of Data BaseNormalization of Data Base
Normalization of Data Base
 
Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)
 
Lecture 1&2(rdbms-ii)
Lecture 1&2(rdbms-ii)Lecture 1&2(rdbms-ii)
Lecture 1&2(rdbms-ii)
 
Java script
Java scriptJava script
Java script
 
File Management
File ManagementFile Management
File Management
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
DHTML
DHTMLDHTML
DHTML
 
CSA lecture-1
CSA lecture-1CSA lecture-1
CSA lecture-1
 
Relational database management system (rdbms) i
Relational database management system (rdbms) iRelational database management system (rdbms) i
Relational database management system (rdbms) i
 

Recently uploaded

Jason Potel In Media Res Media Component
Jason Potel In Media Res Media ComponentJason Potel In Media Res Media Component
Jason Potel In Media Res Media ComponentInMediaRes1
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
The Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressThe Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressMaria Paula Aroca
 
Sarah Lahm In Media Res Media Component
Sarah Lahm  In Media Res Media ComponentSarah Lahm  In Media Res Media Component
Sarah Lahm In Media Res Media ComponentInMediaRes1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Osopher
 
Transdisciplinary Pathways for Urban Resilience [Work in Progress].pptx
Transdisciplinary Pathways for Urban Resilience [Work in Progress].pptxTransdisciplinary Pathways for Urban Resilience [Work in Progress].pptx
Transdisciplinary Pathways for Urban Resilience [Work in Progress].pptxinfo924062
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsArubSultan
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 

Recently uploaded (20)

Jason Potel In Media Res Media Component
Jason Potel In Media Res Media ComponentJason Potel In Media Res Media Component
Jason Potel In Media Res Media Component
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
The Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressThe Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian Congress
 
Sarah Lahm In Media Res Media Component
Sarah Lahm  In Media Res Media ComponentSarah Lahm  In Media Res Media Component
Sarah Lahm In Media Res Media Component
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
Israel Genealogy Research Assoc. April 2024 Database Release
Israel Genealogy Research Assoc. April 2024 Database ReleaseIsrael Genealogy Research Assoc. April 2024 Database Release
Israel Genealogy Research Assoc. April 2024 Database Release
 
Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
 
Transdisciplinary Pathways for Urban Resilience [Work in Progress].pptx
Transdisciplinary Pathways for Urban Resilience [Work in Progress].pptxTransdisciplinary Pathways for Urban Resilience [Work in Progress].pptx
Transdisciplinary Pathways for Urban Resilience [Work in Progress].pptx
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristics
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 

Sql fundamentals

  • 1. SQL Fundamentals SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database. SQL is like plain English: easy to understand and to write. SQL statements into various categories, which are: •Data Definition Language •Data Manipulation Language •Data Control Language. •Transaction Control Language •Embedded SQL statements
  • 2. Data Definition Language (DDL) statements: Thapar University, Oracle Short Term Course DDL statements are used to define, alter, or drop database objects. The following table gives an overview about usage of DDL statements in ORACLE (a commercially used database):
  • 3. Data Manipulation Language (DML) statements Once the tables have been created, the DML statements enable users to query or manipulate data in existing schemas objects. DML statements are normally the most frequently used commands. The following table gives an overview about the usage of DML statements in ORACLE.
  • 4.
  • 5. Thapar University, Oracle Short Term Course Data Control Language (DCL) A privilege can either be granted to a User with the help of GRANT statement. The privileges assigned can be SELECT, ALTER, DELETE, EXECUTE, INSERT, INDEX etc. In addition to granting of privileges, you can also revoke it by using REVOKE command.
  • 6. Transaction Control Statements (TCL) statements: Thapar University, Oracle Short Term Course TCL statements manage the change made by DML statements, and group DML statements into transactions. The following table gives an overview about the usage of TCL statements in ORACLE.
  • 7. Embedded SQL statements Thapar University, Oracle Short Term Course The SQL statements used to incorporate DDL,DML and transaction control statements within the body of a procedural language program, are known as Embedded SQL statements. The following table gives an overview about the usage of Embedded SQL statements in ORACLE.
  • 8. Oracle Data types The information in a database is maintained in the form of tables and each table consists of rows and columns, which store data, and therefore this data must have some data type i.e the type of data, which is stored in a table.
  • 10. The most commonly used data types  char  varchar or varchar2  number  date  long  long raw/ raw
  • 11. Let us now briefly describe these data types: Char(n) This data type is used to store character strings of fixed size. The size of the character string is determined by the numeric value of n. This data type can hold maximum of 255 characters. When Oracle stores data in a CHAR data type, it will pad the value stored in the column up to the length of the column as declared by the table with blanks. For example: If data type of address field is mentioned as CHAR(40) and address information of a particular record complete in 20 characters, then remaining 20 characters space is padded with blank characters.
  • 12. Varchar(n) / Varchar2(n) This data type is used to store variable length alphanumeric data. It can store maximum of 2000 characters. In case of varchar data type, Oracle will not store padded blank spaces if the value stored in a column defined is less than length of the column as declared by the table with data type VARCHAR2. For example: If data type of address field is mentioned as VARCHAR(40) and address information of a particular record complete in 20 characters, then remaining 20 characters space is not padded with blank characters and memory space of 20 characters is used for some other purposes and not wasted as padded with blank characters.
  • 13. Number (p,s) This data type is used to store numbers fixed or floating point . The precision (p) determines the length of the data while (s), the scale, determines the number of places after the decimal. The NUMBER data type that is used to store number data can be specified either to store integers or decimals with the addition of a parenthetical precision indicator. For example, if you had a column defined to be data type NUMBER(10,3), the number 546.3832 would be stored as 546.383, because after the decimal point we can store 3 digits. It can store a number of 10 digits including a decimal point for example a maximum number of 999999.999 can be stored with data type of NUMBER(10,3).
  • 14. Date This data type, stores date values in a special format internal to Oracle. It offers a great deal of flexibility to users who want to perform date manipulation operations There are also numerous functions that handle date operations more complex than simple arithmetic. The default format in which date is stored is DD-MON-YY. If we want to store date in other format then we have to use the appropriate functions.
  • 15. Long The developer can declare columns to be of LONG data type, which can stores upto 2 gigabytes of alphanumeric text data. The values of long data type cannot be indexed and normal characters functions such as SUBSTR cannot be applied to long values. Long Raw / Raw It is useful to store graphics and sound files when used in conjunction with LONG to form the LONG RAW data type, which can accommodate up to 2 gigabytes of data. Note: A table cannot contain more than one Long column. They cannot be indexed and no integrity constraints can be applied on them (except for NULL and NOT NULL constrain).
  • 16. Simplified Approach To Oracle By Parteek Bhatia