declare

Datatypes in SQL | Database management System



Sharing buttons:

hello everyone welcome to tected again

in this tutorial we will be learning

data types in SQL so I think I need not

to explain what is data type we all

understand so we have to understand what

are the data types basically allowed in

SQL okay so before we go and create

database and store values in it we have

to understand what kind of values we can

store okay so in this lecture we'll be

learning all these kinds which we can

store so this is basically highly

informative tutorial but for the sake of

completion we have to learn this we have

to note down the database the data types

which we can store and basically we need

not to remember all I I also do not

remember all of them except 3 for which

I regularly use for example where care

in ok so let's learn this one by one so

the first one we will start with numeric

data type so under numeric data type we

have int as our first data type and in

stores integer so it stores stores

integer

and what is the range it can store so it

can store - two one four seven four

eight three six four eight I am copying

this value from my notebook - you need

not to remember this okay so this is the

range of integer which we can store in

this data right okay the next one is

small int so let's say I have to store

small numbers then we need not to waste

spaces by creating this integer datatype

okay so we can create small end again it

will store in teaser but the range will

be less so that is it can store three

two seven six eight two plus three two

seven six seven fine

so if we have to store even small

numbers we can go for tiny so it is

quite tiny int again stores integer and

it will store value only positive value

0 to 255 similarly we also have bit data

type so it stores one bit that is either

0 or 1 okay so it will store 0 or 1 so

let's write it 0 to 1 fine we have

another data type that is numeric and it

stores precision specified by users and

this is the range for numeric another

data type is float which stores

floating-point numbers and it is it will

store number - 1 point 7 9 e + 3 0 it to

this one so this is basically hexa

single representation

and we also have real number so real

will against or floating-point numbers

and double-precision floating-point

numbers okay

and the range is again much larger than

this so that is minus three point so

these are data type to store integers or

numbers now we have other data types to

store characters character data types so

in character we have cat okay so it

stores mac maximum 8,000 characters but

it will vary from OS to s OS it will

vary from I mean it will be machine

dependent similarly we have their care

here where can in worker we can specify

even in character we can specify the

number of characters to be stored in

Backyardigans

specify the number of characters to be

stored but in both the differences like

this one will use dynamic memory

allocation okay and it will be more

space wise efficient okay so and this

will use static memory allocation okay

but this will be faster okay because it

uses static static memory allocation

fine so which one we should use in a

case when we need when we know that the

number of characters going to be stored

in a particular field is this much that

is we know the number of characters to

be going to be stored okay if the number

of characters are fixed then we use care

and if it is variable so let's say I am

storing comment by user so that comment

may vary from few characters to

thousands of character somebody can just

write very good okay somebody can write

a long comment so that will there where

care will be a good idea because it will

take less space fine so that's how we

use where can we have another important

data type that is date and time so under

this we have first data type as date

time date time point so this one will

store date time of course so this will

store date in this format for example

January 31st 1980 for something like

this okay now we have another data type

that is date so date will store date in

like this January January 26 1988 time

is a datatype which stores time for

example it will store like 12:30 p.m.

something like this okay

now the last one is most important and

most widely used I always use this data

type to store date thank so that is

timestamp timestamp basically combines

date and time in form of numbers okay so

it will combine date and time in form of

numbers okay so this is most convenient

to use basically what it does is it was

I guess January 1st January 1st 1970 ok

so from January 1st 9

in 70s it starts counting seconds okay

so when you see a timestamp value it

will be something I want to eight four

six seven three four five something like

this will be stored okay and then it

says number of seconds from January 1970

now with reference to this value which

is called basically something uniques

unix starting point or something so from

here it counts the number of seconds so

from this reference you can determine

what is the time it has stored okay so

that's how timestamp works fine so this

was all about data type now maybe this

lecture was quite boring but we have to

understand it and with mainly we have to

remember it is a data type which stores

integer and in case of small integer we

will use small it okay and float data

type of course if we have to store big

numbers then care and we're care we just

learned and this one timestamp okay so

these are widely used apart from it bit

is also used others are also used

depending upon the you know designers

choice so that's that's all for this

lecture in next lecture we will be

learning data definition language okay

so hope to see you in the next lecture

thanks for watching