You are on page 1of 22

Submitted Submitted by:

to: GOURAV
AMAN GOYAL
NEHRA 1608033
(Training C.S.E. (3rd year)
Incharge)
 SQL is a standard language for accessing and
manipulating databases.

SQL stands for Structured Query Language

SQL lets you access and manipulate databases

SQL is an ANSI (American National Standards


Institute) standard
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
SQL can create stored procedures in a database
SQL can create views in a database
SQL can set permissions on tables, procedures,
and views
 The first thing you need to understand about SQL is
that it isn’t a procedural language like FORTRON,
BASIC, C, COBOL, Pascal or Ada. To solve a problem
in one of those languages, you write a procedure that
performs one operation after another until the task is
complete.

 SQL is nonprocedural. To solve a problem with SQL,


instead of telling the system how to get you what you
want, you simply tell it what you want. The DBMS
decides the best way to get you what you asked for.
 RDBMS stands for Relational Database Management
System.

 RDBMS is the basis for SQL, and for all modern


database systems like MS SQL Server, IBM DB2,
Oracle, My SQL, and Microsoft Access.

 The data in RDBMS is stored in database objects


called tables.

 A table is a collections of related data entries and it


consists of columns and rows.
 The Oracle Database (commonly referred to as
Oracle RDBMS or simply as Oracle) is a relational
database management system (RDBMS)
produced and marketed by Oracle Corporation.

 The name Oracle comes from the code-name of a


CIA-funded project.

 In 2003, Oracle Corporation released Oracle


Database 10g, which supported regular
expressions. (The g stands for "grid";
emphasizing a marketing thrust of presenting
10g as "grid computing ready".
A SELECT statement retrieves information from
the database. Its capabilities are:

Projection: Choose the columns in a table that are


returned by a query.

Selection: Choose the rows in a table that are


returned by a query.

Joining: Bring together data that is stored in different


tables by specifying the link between them.
When retrieving the data from the database, you
may need to do the following:

Restrict the rows of data that are displayed.


Specify the order in which rows are displayed.

There are SQL statements that you use to perform these


actions.
Using the WHERE Clause
Using the ORDER BY Clause
Functions are very powerful features of SQL. They
can be used to do the following:

Perform calculations on data


Modify individual data items
Manipulate output for groups of rows
Formats dates and numbers for display
Convert column data types

SQL functions always return a value.


 What are Group Functions?

Group functions operate on sets of rows to give one


result per group.
These sets may comprise the entire table or the table
split into groups.
A Join is used to view information from multiple tables.
Therefore, you can join tables together to view
information from more than one table.

Eg.:
 Employee IDs exist in EMPLOYEES table
 Department IDs exist in both the EMPLOYEES &
DEPARTMENTS tables
 Department names exist in DEPARTMENTS table

To produce the report you need to link the EMPLOYEES &


DEPARTMENTS tables.
 Using a subquery to solve a problem

Suppose you want to write a query to find out who


earns a salary greater than Abel’s salary.
To solve this problem you need two queries: one to find
how much Abel earns, & a second query to find who
earns more than that amount.
You can solve this problem by placing one query inside
the other.
The inner query (subquery) returns a value that is used
by the outer query (main query).
Single-row
Subqueries
Return only one row
from inner SELECT
statement

Multiple-row Return more than one


Subqueries
row from inner SELECT
statement
Set operators combine the results of two
or more component queries into one result
 UNION- All distinct rows selected by either query

 UNION ALL- All rows selected by either query,


including all duplicates

 INTERSECT- All distinct rows selected by both


queries

 MINUS- All distinct rows that are selected by the first


SELECT statement and not selected in second
SELECT statement
thanks

You might also like