Tuesday, 19 July 2016

SQL DATA TYPES

We required SQL to deal with database,it means to select any data or update anything or delete or to store any data in database.
So now we ill learn how to use SQL in order to become developer and remember that SQL full form is STRUCTURED QUERY LANGUAGE. It means in SQL everything structured and deals with Queries only.

Before we go for SQL ,lets learn some basics.

1)
Table: here table means ,you can assume in MS word table but here table is object which is used to store data and it contains columns as well.

2)
SCHEMA : Schema is nothing but user who connects to database, in Database each user will have their own schema.we ill discuss more about this in coming posts.

3)
DATA TYPES: In SQL we use following data types mainly.

a) CHAR –Its used to store character values.
Syntax : CHAR(10)–It means you can store 10 bytes ,here 10 is size.
You can specify size up to 2000 bytes.

b) VARCHAR2 –Its also used to store character values same as CHAR data type but advantage of varchar2 data type is,it takes required storage space only.
eg : CHAR(20) and VARCHAR2(20) –Here both ill allow up to 20 bytes storage space but suppose in some cases we may store only 10 bytes.In this kind of scenarios CHAR(20) Will not give it back rest of 10 bytes storage space but VARCHAR2(20) gives back so that 10 bytes space can be used somewhere else.
You can specify size up to 4000 bytes

c) DATE -Its used to store date values.
Syntax : DATE
note: for DATE data type we no need to specify SIZE.

d) NUMBER –its Used to store number values
Syntax: NUMBER(10,2)
here 10 means it can store up to 10 digits but last digits would be decimal values.
eg: 12345678.95

e) INTEGER-its also used to store number values but it doesn’t allow decimal values
so whenever you want to store decimal value then go for NUMBER Data type else use INTEGER Data type.
SYNTAX: INTEGER
For integer datatype size is not required to mention.

There some other data type which never used now a days so just learn above data types.

No comments:

Post a Comment