Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

Chapter 4 - Structured Query Language - (SQL)

Uploaded by

roshanjadhav2023
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Chapter 4 - Structured Query Language - (SQL)

Uploaded by

roshanjadhav2023
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Chapter : 4

Structured Query Language (SQL)


-----------------------------------------------------------------------------------------------------------------------------------------

SQL
● SQL stands for Structured Query Language. It is used for storing and managing data in a

relational database management system (RDMS).

● It is a standard language for Relational Database System. It enables a user to create, read,

update and delete relational databases and tables.

● All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use SQL as their

standard database language.

● SQL allows users to query the database in a number of ways, using English-like statements.

Rules:
SQL follows the following rules:
● Structure query language is not case sensitive. Generally, keywords of SQL are written in

uppercase.

● Statements of SQL are dependent on text lines. We can use a single SQL statement on one or

multiple text line.

● Using SQL statements, you can perform most of the actions in a database.

● SQL depends on tuple relational calculus and relational algebra.

Characteristics of SQL
● 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.

● SQL is used to create a view, stored procedure, function in a database.

● SQL allows users to set permissions on tables, procedures, and views.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------
SQL process:

● When an SQL command is executing for any RDBMS, then the system figure out the best way to

carry out the request and the SQL engine determines that how to interpret the task.

● In the process, various components are included. These components can be optimization

Engine, Query engine, Query dispatcher, classic, etc.

● All the non-SQL queries are handled by the classic query engine, but SQL query engine won't

handle logical files.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------

Advantages of SQL
There are the following advantages of SQL:

High speed
Using the SQL queries, the user can quickly and efficiently retrieve a large amount of records from a
database.

No coding needed
In the standard SQL, it is very easy to manage the database system. It doesn't require a substantial
amount of code to manage the database system.

Well defined standards


Long established are used by the SQL databases that are being used by ISO and ANSI.

Portability
SQL can be used in laptop, PCs, server and even some mobile phones.

Interactive language
SQL is a domain language used to communicate with the database. It is also used to receive answers
to the complex questions in seconds.

Multiple data view


Using the SQL language, the users can make different views of the database structure.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------
SQL Datatype
● SQL Datatype is used to define the values that a column can contain.
● Every column is required to have a name and data type in the database table.

Datatype of SQL:

1. Binary Datatypes
There are Three types of binary Datatypes which are given below:

Data Type Description

binary It has a maximum length of 8000 bytes. It contains fixed-length binary data.

varbinary It has a maximum length of 8000 bytes. It contains variable-length binary data.

image It has a maximum length of 2,147,483,647 bytes. It contains variable-length binary data.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------
2. Approximate Numeric Datatype :
The subtypes are given below:

Data type From To Description

float -1.79E + 308 1.79E + 308 It is used to specify a floating-point value e.g. 6.2, 2.9 etc.

real -3.40e + 38 3.40E + 38 It specifies a single precision floating point number

3. Exact Numeric Datatype


The subtypes are given below:

Data type Description

int It is used to specify an integer value.

smallint It is used to specify small integer value.

bit It has the number of bits to store.

decimal It specifies a numeric value that can have a decimal number.

numeric It is used to specify a numeric value.

4. Character String Datatype


The subtypes are given below:

Data Description
type

char It has a maximum length of 8000 characters. It contains Fixed-length non-unicode characters.

varchar It has a maximum length of 8000 characters. It contains variable-length non-unicode characters.

text It has a maximum length of 2,147,483,647 characters. It contains variable-length non-unicode


characters.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------
5. Date and time Datatypes
The subtypes are given below:

Datatype Description

date It is used to store the year, month, and days value.

time It is used to store the hour, minute, and second values.

timestamp It stores the year, month, day, hour, minute, and the second value.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------
SQL Operator
An operator is a reserved word or a character used primarily in an SQL statement's WHERE clause to
perform operation(s), such as comparisons and arithmetic operations.
There are various types of SQL operator:

SQL Arithmetic Operators


Let's assume 'variable a' and 'variable b'. Here, 'a' contains 20 and 'b' contains 10.

Operator Description Example

+ It adds the value of both operands. a+b will give 30

- It is used to subtract the right-hand operand from the left-hand operand. a-b will give 10

* It is used to multiply the value of both operands. a*b will give 200

/ It is used to divide the left-hand operand by the right-hand operand. a/b will give 2

% It is used to divide the left-hand operand by the right-hand operand and a%b will give 0
returns reminder.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------
SQL Comparison Operators:
Let's assume 'variable a' and 'variable b'. Here, 'a' contains 20 and 'b' contains 10.

Operator Description Example

= It checks if two operands values are equal or not, if the values are (a=b) is not true
queal then condition becomes true.

!= It checks if two operands values are equal or not, if values are not (a!=b) is true
equal, then condition becomes true.

<> It checks if two operands values are equal or not, if values are not (a<>b) is true
equal then condition becomes true.

> It checks if the left operand value is greater than right operand value, (a>b) is not true
if yes then condition becomes true.

< It checks if the left operand value is less than right operand value, if (a<b) is true
yes then condition becomes true.

>= It checks if the left operand value is greater than or equal to the right (a>=b) is not true
operand value, if yes then condition becomes true.

<= It checks if the left operand value is less than or equal to the right (a<=b) is true
operand value, if yes then condition becomes true.

!< It checks if the left operand value is not less than the right operand (a!=b) is not true
value, if yes then condition becomes true.

!> It checks if the left operand value is not greater than the right operand (a!>b) is true
value, if yes then condition becomes true.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore
Chapter : 4
Structured Query Language (SQL)
-----------------------------------------------------------------------------------------------------------------------------------------
SQL Logical Operators
There is the list of logical operator used in SQL:

Operator Description

ALL It compares a value to all values in another value set.

AND It allows the existence of multiple conditions in an SQL statement.

ANY It compares the values in the list according to the condition.

BETWEEN It is used to search for values that are within a set of values.

IN It compares a value to that specified list value.

NOT It reverses the meaning of any logical operator.

OR It combines multiple conditions in SQL statements.

EXISTS It is used to search for the presence of a row in a specified table.

LIKE It compares a value to similar values using wildcard operator.

-----------------------------------------------------------------------------------------------------------------------------------------------------
Subject : DBMS Class : SE SEM: IV Dr.Anirudh Mangore

You might also like