0% found this document useful (0 votes)
10 views8 pages

Literals Operators Datatypes

The document provides an overview of SQL literals, operators, and data types. It categorizes literals into integer, text, and date types, and outlines various SQL operators including arithmetic, relational, logical, and set operators. Additionally, it describes SQL data types such as NUMBER, CHAR, VARCHAR2, LONG, DATE, RAW, and LONG RAW, detailing their syntax and usage.

Uploaded by

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

Literals Operators Datatypes

The document provides an overview of SQL literals, operators, and data types. It categorizes literals into integer, text, and date types, and outlines various SQL operators including arithmetic, relational, logical, and set operators. Additionally, it describes SQL data types such as NUMBER, CHAR, VARCHAR2, LONG, DATE, RAW, and LONG RAW, detailing their syntax and usage.

Uploaded by

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

SQL LITERALS

A literal is a fixed value. It doesn‟t change its value. It is also called constant. In SQL, literals are
classified as follows:

LITERALS

NUMBER TEXT DAT

INTEGER FLOATING
Integer Literals:
Any number without fractional part is called an integer
constant. The integer numbers can contain digits (0..9) and
sign (+ or -). An integer constant must not contain commas
and spaces.
Eg: 3 -3 15 -15 2500 -9700 etc.
Text Literals:
A sequence of one or more characters enclosed within single
quotes is called text literal. These are also known as string
literals or character strings;
Eg:
„Nellore‟
„SQL-99‟
„Vikrama Simhapuri University‟
Date Literals:
Any date value enclosed within single quotes is called date
literal. The date literals must be in the format „DD- MON-YYYY‟.
Eg: ‟12-JUL-2022‟
SQL OPERATORS
An operator is a symbol or keyword used to perform arithmetic and logical operations. In SQL, operators are
classified into the following types. They are
1 Arithmetic operators
2 Relational (comparison)
operators3 Logical operators
4 Set operators
5 Special relational operators
1 Arithmetic Operators: Arithmetic operators are used to perform mathematical operations
likeaddition,subtraction etc.
Operator Meaning Example Result
+ Addition 10+3 13
- Subtraction 10-3 7
* Multiplication 10*3 30
/ Division 10/3 3.333
10 | | 30 1030
|| Concatenation
10 | | „AB‟ 10AB
1 Relational (comparison) Operators: The relational operators compare two values and give the result either
trueor false. These are used to form simple conditions.
Operator Meaning Example Result
> Greater than 50>40 T
< Less than 50<40 F
= Equal to 50=40 F
>= Greater than or equal to 50>=40 T
<= Less than or equal to 50<=40 F
!= Not equal to 50!=40 T

Logical Operators: The logical operators combine two conditions or to negate the result of a condition and
givethe result either true or false. These are used to form compound conditions.
Operator Meaning Example Result
AND Gives true if both conditions are true 40>50 AND 50>30 F
OR Gives true if any or both conditions are true 40>50 OR 50>30 T
Gives true if condition is false
NOT NOT (40>50) T
Gives false if condition is true

4 Set Operators:
Set operators are used to combine the output of two queries. These are used to form union queries.
Operator Meaning
UNION Returns all distinct rows from both queries
UNION ALL Returns all rows from both queries
INTERSECT Returns only common rows of both queries
MINUS Returns all rows of the first query but not in the second query
5.Special Comparison(Relational) Operators:

The special operators compare values and give the result either true
or false. These operators will simplify the complex conditions. They
can be used in conditions.

Operator Meaning
IN Compares equal to any value in the list of values
BETWEEN Compares range of values
IS Compares nulls
LIKE Compares string patterns
ALL Compares all values within the list
ANY or SOME Compares any or some of values in the list
SQL DATA TYPES
The data type is the characteristic of a column in a table. It specifies
the type of data to be entered into the column of a table. The data
types are used in creating a table structure. SQL data types are as
follows
NUMBER data type: This data type allows numeric values only.
Syntax: NUMBER (L,D)
L indicates length i.e. number of digits. D indicates the number of
decimal places within the length
The length should be in the range from 1 to 38 digits. The length
is optional. If it is omitted, it takes 38 digits as default length.
Eg: i) number ii) number (9) iii) number (9,2)
CHAR data type: This data type allows any type of character i.e.
alphabet, digit, or symbol. It stores fixed length strings
Syntax : CHAR(size)
The „size‟ indicates maximum number of characters allowed in
each cell of column
The „size‟ must be in the range from 1 to 2000 bytes
The „size‟ is optional. If it is omitted, the default length is 1
character Eg: i) char ii) char(20)
VARCHAR2 data type: This data type allows any type of character i.e.
alphabet, digit, or symbol. It stores variable length strings.
syntax: VARCHAR(size)
The „size‟ indicates maximum number of characters allowed in each
cell of column
The „size‟ must be in the range from 1 to 4000 bytes Eg: varchar2(20)
LONG data type: This data type allows any type of character i.e.
„alphabet, digit, or symbol. It stores variable length strings. It can store
upto 2 Giga Bytes in each cell.
Syntax: LONG Eg: long
DATE data type: This data type allows date values. Date values must be
entered in „DD-MON-YYYY‟ format. Syntax: DATE
Eg: date
RAW data type: It is used to store small size multimedia information like
images, audio and video. It stores data in binary or hexadecimal format
Syntax: RAW(size)
• The „size‟ must be in the range from 1 to 255 bytes Eg: raw(100)
7 LONG RAW data type: It is used to store large size multimedia
information like images, audio and video. It stores data in binary or
hexadecimal format.
Syntax: LONG RAW Eg: long raw

You might also like