2.4_sql

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Database Management System

By
Mr. Parag R. Sali
Lecturer
Department of Computer Technology
SNJB’s Shri. Hiralal Hastimal ( Jain Brothers)
Polytechnic, Chandwad
Program Name: Computer Engineering Group
Program Code : CO/CM/CW
Semester : Third
Course Title : Database Management System
Course Code : 22319

Structured Query Language


INTRODUCTION TO SQL
STRUCTURED QUERY LANGUAGE (SQL)
 SQL is a standard language for storing, manipulating and
retrieving data in databases.
 SQL It is used to communicate with database
 SQL statements are used to perform different operations on
database like insertion, deletion, modification.
 SQL is categorized as declarative language not procedural
 SQL is used to perform C.R.U.D (Create, Retrieve, Update &
Delete) operations on relational databases.
 SQL can also perform administrative tasks on database such
as database security, backup, user management etc.
CHARACTERISTICS OF SQL

 SQL allow user to create, update, delete and retrieve data from
database.
 In SQL all keywords of SQL can be expressed in any combination
of upper and lower case character (case insensitive)
 SQL is easy to learn.
 SQL is used to access data from relational database management
systems.
 SQL can execute queries against the database.
 SQL is used to describe the data.
 SQL is used to define the data in the database and manipulate it
when needed.
 SQL is used to create and drop the database and table.
ADVANTAGES OF SQL

 High speed
 No coding needed

 Portability

 Interactive language

 Easy to learn and understand

 Multiple data views

 Complete language for database

 Used in internet
DATA TYPES IN SQL
 In SQL we store data in tabular from, so while creating
table we have to assign data type to the columns.
 Data type are used to decide which type of data the
column can hold/store
1. CHAR(Length):
• CHAR data type accept character or string type of data
• It is fixed length of data
• If value having lower size than the size of CHAR data type,
the remaining space is filled with blanks characters and its
get wasted.
• Example: CHAR(15)/character(15)
‘Polytechnic’
2. VARCHAR(length):
• VARCHAR data type accept character or string type of data
• It is variable length of data
• If value having lower size than the specified length, the
remaining space will be reutilized further it does not get
wasted.
• Example: VARCHAR(15)
‘Polytechnic’

3. Boolean:
• The Boolean data type can accepts value either TRUE or
FALSE
• No need to declare size for Boolean data type
• True or false are case insensitive
• Example : TRUE, True, true, FALSE, False
4. INTEGER or int : (4 byte)
• The INTEGER data type used to accepts numeric values with default
scale as zero
• If you assign a numeric value with a precision and scale to an
INTEGER data type, the scale portion truncates, without rounding.
• Example: Int
543, 0, 1234.36

5. SMALLINT : (2 byte)
• The INTEGER data type used to accepts numeric values
with default scale as zero
• If you assign a numeric value with a precision and scale to an
INTEGER data type, the scale portion truncates, without
rounding.
• Example: smallint
543, 0, 1234.36
6. DECIMAL (p, s):
• The DECIMAL data type used to accepts floating point values.
• Precision means total no of digits, both before and after the decimal
point. The range of precision is 1-38.
• Scale is the no. of digits after decimal point. Scale can only be specified
if precision is specified, scale must be less than or equal to precision.
• Example: DECIMAL (10,3)
Decimal (15,5)
1233.8765432
543, 0, 1234.3631(Final digit is truncated)

7. Float :
• The FLOAT data type used to accepts approximate numeric values,
for which you may define a precision up to a maximum of 64.
• Example: Float (8)
543, 0, 1234.36345
8. TIME :
• The TIME data type used to time values.
• No size required when declaring a TIME data type
• The format is : HH:MM:SS
• The values should be enclosed in single quotes, preceded by keyword
TIME
• Example: TIME ‘3:10:20’

9.DATE :
• The DATE data type used to accepts date type of values.
• No need to define size for DATE data type
• The values should be enclosed in single quotes, preceded by keyword
DATE
• Values can be specified in the form:
YYYY:MM:DD.
• Example: DATE ‘2020-08-24’
COMPONENTS OF SQL
DDL, DML, DCL, TCL,DQL
 Database languages are categorized as follows

DDL

Components of SQL
DML

DCL

TCL

DQL
DATA DEFINITION LANGUAGE (DDL)
 Data definition language is used to define data and their
relationship to other type of data
 It is used to create tables, dictionaries and files in database
 Statements/ commands comes under DDL language are :
 Create: used to create database instance
 Alter : used to alter the structure of database
 Drop: used to drop database instances
 Rename : used to rename database instances
 Truncate : used to truncate the database instances
 Desc : used to display the structure of object
DATA MANIPULATION LANGUAGE (DML)
 Data manipulation language is used for accessing and
manipulating data in a data base.
 DML language allow user to insert, update and delete
data from data base
 Statements/ commands comes under DML language are
:
 Insert : it is used to insert record into table
 Update : it is used update record in table
 Delete : it is used to delete record from table

You might also like