Ch1 Introduction To SQL
Ch1 Introduction To SQL
TO SQL CLASS IX
LEARNING OBJECTIVE
▪Introduction to SQL
▪Relational Database, Component of Database
▪Understanding SQL & its features
▪Data Types used in SQL
INTRODUCTION TO SQL
▪RDBMS
▪RDBMS stands for Relational Database Management System.
▪RDBMS is the basis for SQL, and for all modern database systems
such as MS SQL Server, IBM DB2, Oracle, MySQL, and
Microsoft Access.
▪The data in RDBMS is stored in database objects called tables. A
table is a collection of related data entries and it consists of
columns and rows.
TERMINOLOGY
▪ Table: Collection of rows and columns that contains useful data/information is called a
table. A table generally refers to the passive entity which is kept in secondary storage
device.
▪ Relation: Relation (collection of rows and columns) generally refers to an active entity on
which we can perform various operations.
▪ Database: Collection of logically related data along with its description is termed as
database.
▪ Tuple: A row in a relation is called a tuple.
▪ Attribute: A column in a relation is called an attribute. It is also termed as field or data
item.
TERMINOLOGY
Just like any other programming language, the facility of defining data
of various types is available in SQL also. Following are the most
common data types of SQL.
▪NUMBER
▪CHAR
▪VARCHAR / VARCHAR2
▪DATE
▪LONG
DATA TYPES USED IN SQL
NUMBER
Used to store a numeric value in a field/column. It may be decimal, integer or
a real value. General syntax is
Number(n,d)
Where n specifies the number of digits and d specifies the number of digits to
the right of the decimal point.
e.g marks number(3) declares marks to be of type number with maximum
value 999.
pct number(5,2) declares pct to be of type number of 5 digits with two digits to
the right of decimal point
DATA TYPES USED IN SQL
CHAR
Used to store character type data in a column. General syntax is
Char (size)
where size represents the maximum number of characters in a column.
The CHAR type data can hold at most 255 characters.
e.g name char(25)declares a data item name of type character of upto 25
size long.
DATA TYPES USED IN SQL
VARCHAR/VARCHAR2
This data type is used to store variable length alphanumeric data.
DATE
Date data type is used to store dates in columns. SQL supports the
various date formats other that the standard DD-MON-YY.
e.gdob date; declares dob to be of type date.
LONG
This data type is used to store variable length strings of upto 2 GB size.
e.gdescription long;
EXPECTED LEARNING OUTCOME