You are on page 1of 2

Data Types:-

A Data Type Specifies What type of Data to be allowed in A Particular


column
And amount of memory to be allocated

--> Character Data types


Character Data types are of Two types

ASCII UNICODE
-------- ----------
CHAR NCHAR
VARCHAR NVARCHAR
VARCHAR(MAX) NVARCHAR(MAX)

CHAR:-
* This Datatype is USed for Storing the character Data
* IT Allows to store upto '0 to 8000' Characters
* This Datatype is Recommended for the Fixed Length Column Values

Eg:- Gender CHAR(1) -----> ('M'/'F'/'O')---


>(MALE,FEMALE,OTHERS)
MaritalStatus CHAR(1) -----> ('M'/'S')
---->(Married/Single)

VARCHAR:-
* Just like CHAR Datatype VARCHAR Datatype allows the Character Data
upto '0 to 8000' Characters
* Recommended for Variable Length Fiels/Columns.
* IN VARCHAR Extra Bytes are Released.

Eg:- EmployeeName VARCHAR(100)----->'Chandra sekhar')

VARCHAR(MAX):-
* This Datatype is similar to VARCHAR Datatype. only Difference is it
will allow the Data upto 2GB.

NOTE:-
*"NCHAR,NVARCHAR,NVARCHAR(MAX)" Are similar to "CHAR,VARCHAR,VARCHAR(MAX)"
*"CHAR,VARCHAR,VARCHAR(MAX)" Allows ASCII Charaters
that includes (256 charchers) (A-z,0-9,special charchers)
*"NCHAR,NVARCHAR,NVARCHAR(MAX)" Along with ASCII values
it ALLows UNICODE values as well 'Chinese', 'Japanese','Hindi'
etc.;

---> Integer Datatype


* Allows Numbers without Decimal part.

TINYINT 1BYTE 0 To 255


SMALLINT 2BYTES -32768 To 32767
INT 4BYTES -214,74,83,648 TO 214,74,83,647
BIGINT 8BYTES

----> NUMERIC(P):-
* Allows Numbers Without Decimal Particular
* USe this Datatype When the Values is based on the Number of Digits
* Allow Numbers upto 38 Characters
Eg:- BankAccNumber NUMERIC(11)-- Allows numbers upto 11 digits
09916786161 ------> VALID (As length is 11 digits it is
valid)
099167 ------> VALID (As Length is less than 11
digits it is invalid)
099167861611------> INVALID (As Length is More than 11
digits it is invalid)
B9916786161------> INVALID (Even though length is 11
digits it is invalid

because it contains character 'B')

----> NUMERIC(P,S):-
* Allows Numbers with Decimal Values (floats)
* 'P' Stands for Precision. It defines Total Number of digits to be
allowed (includes after decimal part)
* 'S' Stands for Scale. It Defines number of digits to be allowed
after Decimal

Eg:- Salary NUMERIC(7,2)


60000 VALID
80000.54 VALID
800000.54 INVALID (as total number of digits is 8 it is
invalid)

----> Currency types:-


* Currecy types are used for fields related to money

SMALLMONEY 4BYTES -214748.3648 TO 214748.3647


MONEY 8BYTES

----> DATE & TIME:-


*Used for Fields to store Date or Time values
* Differnt types of Date & Time datatypes are :
1)DATE -----> Allows Only DATE
2)TIME -----> Allows only TIME
3)DATETIME -----> Allows Date & TIME

Eg:- DateOfJoining DATE ---> '2023-06-19'


LoginTime TIME
LastUpdatedon DATETIME

---->Binary Types:-
* Binary Datatypes are used fro storing the Multimedia Objects
Like :- Audio,Video,Images etc.;
* Differnt types of Binary datatypes are :
1)Binary --------> Allows upto o-8000 Bytes
2)VARBiary --------> Allows upto 0-8000 Bytes ( Extra
Bytes will be released)
3)VARBiary(MAX) --------> Allows upto 2GB

Note:- In Binary Datatype Extra Bytes memory will be wasted.

You might also like