EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login

Oracle Data Types

By Priya PedamkarPriya Pedamkar

Home » Data Science » Data Science Tutorials » Oracle Tutorial » Oracle Data Types

Oracle Data Types

Introduction to Oracle Data Types

Data type in Oracle database can be defined as fixed set of properties which is associated with every value of every column which in broader sense means that every value has a data type, which is associated with a specific kind of storage or memory properties like memory space, a specific range to which a value associated with that particular data type can extend, a specific set of constraints associated with it and it is specified for each column present in a table in a database.

List of Oracle Data Types

Given below is the list of oracle data types:

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

1. Character Data Type

Given below are the different character data types.

  • char(size): It is used to store fixed length character string. It has a maximum size of 2000 bytes.
  • varchar2(size): It is used to store variable length character string. It has a maximum size from 1byte to 4KB.
  • nvarchar2(size): It is used to store variable length Unicode character string. The upper limit is 4000 bytes.
  • long: It is also used to store variable length string and it is backward compatible. It can be used to store up to 2 gigabytes.
  • raw: It is variable length binary strings. It has a maximum size of 2000 bytes.
  • long raw: It is variable length binary strings and it is backward compatible. It has a maximum size of 2GB.

Example:

In this example we are going to create a table t1 with three columns each column having a different character data type and then insert a row of data into these columns. Once after we have done that we will use DUMP() function to find the details of each column.

Code:

Creating table:

CREATE TABLE t1 (
x CHAR(10),
b VARCHAR2(10),
z raw(10)
);

Inserting values into table:

INSERT INTO t1(x, b, z )
VALUES('Nil', 'Nil', '');

Selecting table:

SELECT
x,
DUMP(x),
b,
DUMP(b),
z,
DUMP(z)
FROM
t1;

Let us execute the queries in SQL developer and check the result.

Output:

Oracle Data Types 1

As we can see in the above screen shot the DUMP function returns the detailed information of x, b and z columns.

2. Numeric Data Type

Given below are the different numeric data types present in Oracle:

  • number(p, s): This is a numeric data type which has to arguments ’p’ is for precision and ‘s’ is scale. For example if number(8, 3) which means it has five digits before decimal and three digits after decimal. The precision range from 1 to 38 and scale is from range -84 and 127.
  • dec(p, s): It is a float type numeric data type where ‘p’ is precision and ‘s’ is scale. The precision ranges from 1 to 38. Here also dec(3, 1) means 2 digits before decimal and one digit after decimal.

Example:

In this example we are going to create a table named number_example with two columns x and y which is of data type number and dec. Once the table is created we are going to insert some data and then check the contents of the table by using a SELECT command.

Code:

Creating table:

CREATE TABLE number_example (
x NUMBER(6, 2), y dec(6,2)
);

Inserting values into table:

INSERT INTO number_example
VALUES(100.99, 101.99);
INSERT INTO number_example
VALUES(80.552, 11.552);

Selecting table:

select * from number_example;

Let us run the queries in SQL developer and check the result.

Output:

Oracle Data Types 2

As we can see in the screen shot that the size was declared (6, 2) so the second row contents were rounded to two digits after decimal.

Popular Course in this category
Sale
Oracle Training (14 Courses, 8+ Projects)14 Online Courses | 8 Hands-on Projects | 120+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (8,980 ratings)
Course Price

View Course

Related Courses
Oracle DBA Database Management System Training (2 Courses)All in One Financial Analyst Bundle - 250+ Courses, 40+ Projects

3. Date Data Type

We are going to declare about the Date data types.

  • date: As the name suggest it is used to store date type string values.
  • timestamp: It gives fractional seconds precision and it will be a number between 0 and 9.

Example:

In this example we will create a table data_example with columns x and y having data types as DATE and TIMESTAMP respectively. We will then insert a row with values for both columns and then use SELECT statement to see the contents of the table.

Code:

Creating table:

CREATE TABLE date_example (
x DATE, y TIMESTAMP(2)
);

Inserting values into table:

INSERT INTO date_example
VALUES(sysdate, LOCALTIMESTAMP(2));

Selecting table:

select * from date_example;

Let us execute the queries in SQL Developer and check the result.

Output:

Date

As we can see the column with TIMESTAMP data type gives us more accurate fractional time as compared to Date type.

4. Large Object Data Type

This type of data types are also known as LOB data types.

  • blob: It is a type of data type which stores unstructured binary large objects and it can store up to 4 GB of binary data.
  • clob: It is used to store single-byte and multi-byte character data and it can also store up to 4 GB of character data.
  • nclob: It is used to store Unicode data. It can store up to 4 GB of character text data.
  • ROWID data types: Rowid is a fixed length binary data and the format is BBBBBBB.RRRR.FFFFF where BBBBBBB is the block in the database file, RRRR is the row in the block and FFFFF is the database file.

Example:

Each row in an oracle database has an address. In this example we will try to get the row address by querying the pseudo column rowid which is of type ROWID.

Code:

select rowid , name from employee where employee_id ='AD001';

Let us now execute the query in SQL developer and check result.

Output:

Large

Recommended Articles

This is a guide to Oracle Data Types. Here we discuss the introduction to Oracle Data Types along with the list of data types respectively. You may also have a look at the following articles to learn more –

  1. Oracle LOCK TABLE
  2. Oracle REGEXP_REPLACE
  3. Oracle Check Constraint
  4. Oracle CARDINALITY

Oracle Training (14 Courses, 8+ Projects)

14 Online Courses

8 Hands-on Projects

120+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Oracle Tutorial
  • Basic
    • Oracle Marketing Cloud
    • What is Oracle?
    • Career in Oracle
    • How to Install Oracle
    • Oracle Versions
    • What Is Oracle Database
    • Oracle Data Warehousing
    • Oracle Warehouse Builder
    • Career In Oracle Database Administrator
    • Career In Oracle DBA
    • What is Oracle RAC
    • Oracle DBA
    • Oracle? Vanderbilt
    • What is RMAN Oracle
    • Oracle Database Administration
    • Oracle Operators
    • Oracle Constraints
    • Oracle number
    • Oracle Data Types
    • Oracle UNIQUE Constraint
    • Oracle Check Constraint
  • Joins
    • Joins in Oracle
    • Inner Join in Oracle
    • Oracle Cross Join
    • Left Join in Oracle
    • OUTER Join in Oracle
    • Oracle Full Outer Join
    • Natural Join in Oracle
    • Oracle Self Join
    • Oracle hash join
    • Oracle? Update with Join
  • Oracle SET Operators
    • UNION in Oracle
    • Oracle UNION ALL
    • INTERSECT in Oracle
    • MINUS in Oracle
  • Advanced
    • Timestamp to Date in Oracle
    • Oracle Describe Table
    • Oracle Clauses
    • Oracle Having Clause
    • Oracle FOREIGN Key
    • PIVOT in Oracle
    • Oracle Alter Table
    • Oracle Queries
    • Oracle Views
    • Oracle Window Functions
    • Oracle String Functions
    • Oracle Date Functions
    • Oracle Analytic Functions
    • Oracle Aggregate Functions
    • Select in Oracle
    • INSERT in Oracle
    • DISTINCT in Oracle
    • Function in Oracle
    • Oracle GROUP_CONCAT
    • Oracle INSTR()
    • Oracle CONVERT
    • Oracle LENGTH()
    • Oracle EXISTS
    • Oracle REPLACE()
    • Oracle MERGE
    • Oracle LEAD()
    • Oracle EXTRACT()
    • Oracle LISTAGG()
    • Oracle SYS_CONTEXT()
    • Oracle COALESCE
    • Oracle NVL()
    • Oracle SYSDATE()
    • Oracle?Date Format
    • Oracle SYS_GUID()
    • Oracle WILDCARDS
    • Oracle Synonyms
    • Oracle Subquery
    • BETWEEN in Oracle
    • FETCH in Oracle
    • Oracle Index
    • Oracle Function-based Index
    • Oracle UNIQUE Index
    • Oracle Bitmap Index
    • Oracle Column
    • Oracle Triggers
    • Oracle Procedures
    • Sample Database for Oracle
    • Oracle LIKE Operator
    • ORDER BY in Oracle
    • Oracle ORDER BY DESC
    • GROUP BY in Oracle
    • Oracle GROUP BY HAVING
    • Oracle Aliases
    • Table in Oracle
    • Oracle Temporary Table
    • Oracle? Table Partition
    • Oracle rename table
    • Oracle CTE
    • Cursor in Oracle
    • Oracle LOCK TABLE
    • Oracle Tablespace
    • Oracle CARDINALITY
    • Oracle REGEXP
    • Oracle REGEXP_REPLACE
    • Oracle to_date
    • JSON in Oracle
    • Oracle COMMIT
    • Oracle GRANT
    • Oracle MD5
    • Oracle ROLLBACK
    • Oracle Users
    • Oracle TIMESTAMP
    • IF THEN ELSE in Oracle
    • Oracle While Loop
    • Oracle Clone Database
    • Oracle Backup Database
    • Oracle? XML
    • Oracle XMLAGG
    • Oracle XMLTABLE
    • Oracle Performance Tuning
    • Oracle B Tree Index
    • Oracle fusion
    • Oracle ebs
    • Oracle GRC
    • Oracle Cloud
    • Oracle HCM Cloud
    • Oracle Integration Cloud
    • Oracle Jinitiator
    • Oracle pathfinder
    • Oracle VirtualBox
    • Oracle Weblogic Server
    • Oracle decode
    • Oracle Exadata
    • Oracle ZFS
    • Oracle? utilities
    • JDBC Driver for Oracle
    • Oracle? DBA Versions
    • Oracle DBA Salary
  • Interview Questions
    • Oracle Interview Questions
    • Oracle Apps Interview Questions
    • Oracle Apps Technical Interview Questions
    • Oracle Database Interview Questions
    • Oracle Forms Interview Questions
    • Oracle PL/SQL Interview Questions
    • Oracle RAC Interview Questions
    • Oracle SOA Interview Questions

Related Courses

Oracle Course Training

Oracle DBA Certification Course

MongoDB Certification Training

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Special Offer - Oracle Training (14 Courses, 8+ Projects) Learn More