Saturday, September 20, 2014

CHAR Data type in Oracle

CHAR Datatype in Oracle / Overview of CHAR Datatype / How to use CHAR type in Oracle to declare and use Attributes? / Oracle CHAR datatype How to?


CHAR Datatype


CHAR datatype is used to store Fixed-length character strings.

Syntax

CHAR[(size[BYTE | CHAR])]

where CHAR is the datatype,
          size is the maximum length of the string to be stored
          BYTE/CHAR would mean the same thing. That is, size in number of Bytes or Characters.


Overview
Datatype
CHAR
Default Size
1 Byte/Character
Minimum Size
1 Byte/Character
Maximum Size
2000 Bytes/Characters
If the value to be stored is shorter than the declared size?
Blank-padded to the actual size declared
If the value to be stored is longer than the declared size?
ERROR
Memory required to store 1 Character
Depends on the character set used. It may vary from 1 byte to 4 bytes.
Permitted Values
Alphanumeric characters with various native character data set support

 What is fixed length? It uses the size number of Bytes to store any value irrespective of the length of the stored values. That is, if the actual value to be stored is less than the size declared, the actual value gets padded with blank spaces to count the size. For example, let us consider the declaration of variable RegNo;
RegNo CHAR(5);
For this declaration, the values that are to be stored and the actual storage along with the total amount of memory consumed is given in the table below;

Declaration
Actual Data
Stored Data
Value to be stored
Bytes needed
Data Stored
Number of Blank-spaces padded
Bytes used
CHAR(5)
‘R101’
4
‘R101 ‘
1
5
CHAR(5)
‘R1001’
5
‘R1001’
0
5
CHAR(5)
‘R1’
2
‘R1  
3
5
CHAR(10)
‘ID1456’
6
‘ID1456   
4
10
CHAR(10)
‘ID’
2
‘ID       
8
10



Note: Preceding blank spaces and intermediate blank spaces in an input will be considered as data.That is, for storing a value ' R101', where this value start with a blank space, we need 5 bytes.


Character based data types - Content

Character Data types in Oracle

Oracle character data types / Character data types used in Oracle / Character data types supported by Oracle / Various character type variable declaration using Oracle

Character Datatypes


Oracle Character Datatypes are used to store alphanumeric character data. The following datatypes are the Character datatypes supported in Oracle.




LOB Character Datatypes                     – CLOB and NCLOB

LONG Datatype                                   – LONG



Data Types in Oracle

Oracle Datatypes / Supported datatypes in Oracle / Datatypes in Oracle (Up to Oracle 12c) / Various datatypes that are used in Oracle variable declaration / List of datatypes supported by Oracle up to Oracle 12c


Complete Guide to Oracle Datatypes (Up to Oracle 12c)


Oracle uses and supports the following built-in Datatype categories in creating tables, declaring variables in PL/SQL etc.

Character Datatypes           – To store and manipulate character based values / strings

Numeric Datatypes             – To store and manipulate numbers

Date Datatypes                  – To store and manipulate date and time

LOB Datatypes                   – To store and manipulate large objects like text based files, images, videos etc.

RAW Datatypes                  - To store graphics, sound, documents etc.

ROWID Datatypes               - To store the addresses of every row in a database.




Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents