0% found this document useful (0 votes)
239 views3 pages

Data Types

PL/SQL provides numeric, character, boolean, and datetime data types. Numeric data types include NUMBER, DEC, DECIMAL, NUMERIC, DOUBLE PRECISION, FLOAT, INT, and INTEGER. Character data types include CHAR, NCHAR, and VARCHAR. PL/SQL also allows declaring variables using these data types and performing operations on them.

Uploaded by

Ughrisha V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
239 views3 pages

Data Types

PL/SQL provides numeric, character, boolean, and datetime data types. Numeric data types include NUMBER, DEC, DECIMAL, NUMERIC, DOUBLE PRECISION, FLOAT, INT, and INTEGER. Character data types include CHAR, NCHAR, and VARCHAR. PL/SQL also allows declaring variables using these data types and performing operations on them.

Uploaded by

Ughrisha V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PL/SQL data types

S.No Date Type & Description

Numeric
1
Numeric values on which arithmetic operations are performed.

Character
2 Alphanumeric values that represent single characters or strings of
characters.

Boolean
3
Logical values on which logical operations are performed.

Datetime
4
Dates and times.

PL/SQL provides subtypes of data types. For example, the data type NUMBER has a subtype called INTEGER. You can use
the subtypes in your PL/SQL program to make the data types compatible with data types in other programs while embedding
the PL/SQL code in another program, such as a Java program.

PL/SQL Numeric Data Types and Subtypes

Following table lists out the PL/SQL pre-defined numeric data types and their sub-types −

S.No Data Type & Description

NUMBER(prec, scale)
1 Fixed-point or floating-point number with absolute value in range 1E-130 to (but
not including) 1.0E126. A NUMBER variable can also represent 0

DEC(prec, scale)
2
ANSI specific fixed-point type with maximum precision of 38 decimal digits

DECIMAL(prec, scale)
3
IBM specific fixed-point type with maximum precision of 38 decimal digits

NUMERIC(pre, secale)
4
Floating type with maximum precision of 38 decimal digits

DOUBLE PRECISION
5 ANSI specific floating-point type with maximum precision of 126 binary digits
(approximately 38 decimal digits)

FLOAT
6 ANSI and IBM specific floating-point type with maximum precision of 126 binary
digits (approximately 38 decimal digits)

INT
7
ANSI specific integer type with maximum precision of 38 decimal digits

INTEGER
8
ANSI and IBM specific integer type with maximum precision of 38 decimal digits
SMALLINT
9
ANSI and IBM specific integer type with maximum precision of 38 decimal digits

REAL
10 Floating-point type with maximum precision of 63 binary digits (approximately 18
decimal digits)

PL/SQL Character Data Types

Following is the detail of PL/SQL pre-defined character data types and their sub-types −

S.No Data Type & Description

CHAR
1
Fixed-length character string with maximum size of 32,767 bytes

NCHAR
4
Fixed-length national character string with maximum size of 32,767 bytes

VARCHAR
5
Variable-length national character string with maximum size of 32,767 bytes

PL/SQL Date Data Types

S.No Data Type & Description

DATE

1 Default date format might be 'DD-MON-YY'

Eg. 01-OCT-12

DATETIME
2
Includes date & time

Example

DECLARE @num1 INTEGER=10;


DECLARE @num2 INT=100;
DECLARE @num3 NUMERIC=1008;
DECLARE @num4 SMALLINT=10353;
DECLARE @n REAL = 10.10;
DECLARE @n1 FLOAT = 10.1023;
DECLARE @n2 DOUBLE PRECISION = 10.10456;
DECLARE @n3 DEC = 1012.1023;
DECLARE @n4 DECIMAL = 1034.10923;
DECLARE @ch1 CHAR = 'A';
DECLARE @ch2 VARCHAR = 'B';
DECLARE @ch3 VARCHAR(10) = 'AASDAS';
DECLARE @ch4 NCHAR = 'c';
DECLARE @d1 DATE = '17-OCT-2022';
DECLARE @d2 DATETIME = '17-OCT-2022 04:14AM';

BEGIN
print 'NUM1 = '+ CAST(@num1 AS VARCHAR);
PRINT 'NUM2 = '+ CAST(@num2 AS VARCHAR);
PRINT 'NUM3 = '+ CAST(@num3 AS VARCHAR);
PRINT 'NUM4 = '+ CAST(@num4 AS VARCHAR);
PRINT 'N = '+ CAST(@n AS VARCHAR);
PRINT 'N1 = '+ CAST(@n1 AS VARCHAR);
PRINT 'N2 = '+ CAST(@n2 AS VARCHAR);
PRINT 'N3 = '+ CAST(@n3 AS VARCHAR);
PRINT 'N4 = '+ CAST(@n4 AS VARCHAR);
PRINT 'CH1 = '+ @ch1;
PRINT 'CH2 = '+ @ch2;
PRINT 'CH3 = '+ @ch3;
PRINT 'CH4 = '+ @ch4;
PRINT 'D1 = '+ CAST(@d1 AS VARCHAR);
PRINT 'D2 = '+ CAST(@d2 AS VARCHAR);
PRINT 'DAY = ' + CAST(DAY(@d1) AS VARCHAR);
PRINT 'MONTH = ' + CAST(MONTH(@d1) AS VARCHAR);
PRINT 'YEAR = ' + CAST(YEAR(@d1) AS VARCHAR);
END;

OUTPUT
NUM1 = 10
NUM2 = 100
NUM3 = 1008
NUM4 = 10353
N = 10.1
N1 = 10.1023
N2 = 10.1046
N3 = 1012
N4 = 1034
CH1 = A
CH2 = B
CH3 = AASDAS
CH4 = c
D1 = 2022-10-17
D2 = Oct 17 2022 4:14AM
DAY = 17
MONTH = 10
YEAR = 2022

Completion time: 2022-10-17T16:27:30.6793701+05:30

You might also like