sql data type
TRANSCRIPT
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 1/15
PROJECT
ONSQL DATA TYPE
BY BHARTI . K. SHARMAOF T.Y.B(COM) A
ROLL NO:108
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 2/15
DEFINITION OF DATA
A Data is collection of a logically related
data.Data involves specifying the types of data (
For Example:-Numeric,Alphanumeric,etc),
structures & rules for data to be stored in thedatabase
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 3/15
DATA TYPES IN SQL
Character Data/Text Data (string)
Numeric Data (Integer & real)
Temporal Data (Data & Time)
Boolean Data (True or False)
Missing Data (Null)
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 4/15
CHARACTER DATA/TEXT
DATA(STRING)
Character data can be stored either as fixed-length or variable-length string.
The maximum length for char column is 255 bytes
whereas varchar column is 65,535. As matter of fact,if the strings are having fixed
length then use char(len) otherwise usevarchar(len)
Values in CHAR and VARCHAR columns are sorted& compared in case-insensitive fashion,unless the
BINARY attribute was specified when the tablewas created
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 5/15
NUMERIC DATA (INTEGER & REAL)
Numeric data means numbers and they can
be positive or negative or zero;with decimal
point or without decimal point.If data is
without decimal point then it is integer & if
data is with decimal point then it is (float).
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 6/15
TEMPORAL DATA (DATA & TIME)
Temporal data means Date and/or Time.
If century is not given then century is assumed from 1970
to 2069 i.e.if you give year as 69 then it is taken as 2069
whereas if you give year as 70 then it is taken as 1970.
Type Default Format Storage Required
DATE YYYY-MM-DD 3 Bytes
DATETIME YYYY-MM-DD HH:MI:SS 8 Bytes
TIMESTAMP YYYY-MM-DD HH:MI:SS 4 Bytes
YEAR YYYY 1 Bytes
TIME HHH:MI:SS 3 Bytes
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 7/15
BOOLEAN DATA (TRUE & FALSE)
Boolean data means true or false.Boolean data value of false is zero
or true is nonzero-(generally 1).Storage required is 1 byte.
ENUM
Enum is a list or enumeration of string values.A column of typeENUM can be set to a value from the list.A list can contain
maximum 65,535 different values.This column can contain NULL
(Stored as 1,2,3…).You can prevent NULL values from being
accepted by declaring the column as NOT NULL when creating atable.Values stored in database are integers.
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 8/15
MISSING DATA (NULL)
In some cases it is not possible or applicable to
provide a value for a particular column in your
table.In this case thr column is said to be
NULL,which means absence of value.NULL is usedfor various cases where a value cannot be supplied
such as Not Applicable or Unknown or Empty Set
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 9/15
NAME :PINKY YADAV
T.Y.BCOM (A)
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 10/15
PRIMARY KEY
A table typically has a column or
combination of columns that contain values
that uniquely identify each row in the table.
This column, or columns, is called theprimary key (PK) of the table and enforces
the entity integrity of the table. Because
primary key constraints guarantee uniquedata, they are frequently defined on an
identity column.
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 11/15
When you specify a primary key constraint for atable, the Database Engine enforces datauniqueness by automatically creating a unique
index for the primary key columns. This indexalso permits fast access to data when theprimary key is used in queries. If a primary keyconstraint is defined on more than one column,
values may be duplicated within one column,but each combination of values from all thecolumns in the primary key constraint definitionmust be unique.
7/30/2019 SQL Data Type
http://slidepdf.com/reader/full/sql-data-type 12/15
AS SHOWN IN THE FOLLOWINGILLUSTRATION, THE PRODUCT AND
VENDORID COLUMNS IN THEPURCHASING.PRODUCTVENDORTABLE FORM A COMPOSITE PRIMARYKEY CONSTRAINT FOR THIS TABLE.THIS MAKES SURE THAT THAT EVERYROW IN THE PRODUCTVENDOR TABLE
HAS A UNIQUE COMBINATION OFPRODUCTID AND VENDORID. THIS