SlideShare a Scribd company logo
1 of 16
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)

SQL commands
SQL commandsSQL commands
SQL commands
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
Data Manipulation Language
Data Manipulation LanguageData Manipulation Language
Data Manipulation Language
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Triggers and active database
Triggers and active databaseTriggers and active database
Triggers and active database
 
MySQL Data types
MySQL Data typesMySQL Data types
MySQL Data types
 
12 SQL
12 SQL12 SQL
12 SQL
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJ
 
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
Array ppt
Array pptArray ppt
Array ppt
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
File organization 1
File organization 1File organization 1
File organization 1
 

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
 
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
 
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

ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscapingDr. M. Kumaresan Hort.
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 

Recently uploaded (20)

ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 

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