0% found this document useful (0 votes)
18 views

Lecture_Data_Types

The document provides an overview of creating a basic table in a database, including defining columns and their data types. It details various data types such as Numeric, Character String, and Date/Datetime, along with their storage sizes and ranges. Additionally, it explains how users can create custom data types using the CREATE TYPE syntax.

Uploaded by

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

Lecture_Data_Types

The document provides an overview of creating a basic table in a database, including defining columns and their data types. It details various data types such as Numeric, Character String, and Date/Datetime, along with their storage sizes and ranges. Additionally, it explains how users can create custom data types using the CREATE TYPE syntax.

Uploaded by

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

Create

Creating a basic table involves naming the table and defining its columns and each column's data type.

➢ Numeric - This type of data stores numerical values. Following Data types fall
in this category: Integer, Float, Real, Numeric, or Decimal.
➢ Character String - This type of data stores character values. The two common
Data Types types are CHAR(n) and VARCHAR(n).
➢ Date/Datetime - This type of data allows us to store date or datetime in a
database table.

Start-Tech Academy
Data Types
Numeric - This type of data stores numerical values.

Storage
Name Description Range
Size
Stores whole numbers,
smallint 2 bytes -32768 to +32767
small range.
Stores whole numbers.Use
-2147483648 to
integer this when you want to store 4 bytes
Numeric typical integers.
+2147483647

Stores whole numbers, -9223372036854775808 to


bigint 8 bytes
large range. 9223372036854775807
up to 131072 digits before
user-specified precision, the decimal point; up to
decimal variable
exact 16383 digits after the
decimal point.

Start-Tech Academy
Data Types
Character String - This type of data stores character values. The two common types are CHAR(n) and VARCHAR(n).

Name Description
character varying(n), varchar(n) variable-length with limit
Character character(n), char(n) fixed-length, blank padded
text variable unlimited length

Start-Tech Academy
Data Types
Date/Datetime - This type of data allows us to store binary objects in a database table.

Name Description Storage Size Low Value High Value

both date and time


timestamp 8 bytes 4713 BC 294276 AD
(no time zone)

date date (no time of day) 4 bytes 4713 BC 5874897 AD


Date-Time
time time of day (no date) 8 bytes 00:00:00 24:00:00

interval 12 bytes time interval -178000000 years 178000000 years

Start-Tech Academy
CREATE TYPE
Users can define data types as per requirements also

➢ CREATE TYPE Dollar as DECIMAL(9,2);

SYNTAX ➢ CREATE TYPE days AS ENUM ('Monday', 'Tuesday', 'Wednesday', 'Thursday',


'Friday', 'Saturday', 'Sunday');

Start-Tech Academy

You might also like