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

Views in SQL, Data Defination Languge,

The document provides an overview of SQL views, including their types, advantages, and how to create them. It also covers aggregate functions in SQL, such as AVG, SUM, MIN, MAX, and COUNT, along with the concept of NULL values and their significance. Additionally, it explains Data Definition Language (DDL) commands used to define and modify database structures.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Views in SQL, Data Defination Languge,

The document provides an overview of SQL views, including their types, advantages, and how to create them. It also covers aggregate functions in SQL, such as AVG, SUM, MIN, MAX, and COUNT, along with the concept of NULL values and their significance. Additionally, it explains Data Definition Language (DDL) commands used to define and modify database structures.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

VIEWS IN SQL, DATA DEFINATION

LANGUGE, AGGREGATE FUNCTIONS, NULL


VALUES
By- Vanshika
VIEWS IN SQL
• Views in SQL are kind of virtual tables.
• View is a result of a stored query.
ADVANTAGES OF VIEW

• To restrict data access.


• To make complex queries easy.
• To provide data independence.
• To present different views of the same table.
TYPES OF VIEWS
• Simple views: logical table created from a single base table.
It does not hold data

• Complex views: logical table created from more than one bas table.
It does not hold data.

• Materialized views: like a physical table that stores query output or intermediate results.
It holds data.
• Let’s create 2 sample tables as student details and student marks.
CREATING VIEWS:
CREATING VIEW FROM
ANOTHER TABLE

• WE HAVE CREATED 2 TABLES AND WE WILL JOIN THEM.


CREATING VIEWS ON
CONDITIONS
• WHERE CONDITION:

• ORDER BY:
AGGREGATE FUNCTIONS
An SQL aggregate function calculates on a set of values and returns a single value.
You can use aggregate function as expression only in the following:
•The SELECT statement, either a subquery or an outer query.
•A HAVING clause.
• AVERAGE FUNCTION:
The AVG() Function Returns The Average Values In A Set.

The Following Is The Syntax Of Average Function.

• SUM FUNCTION:
The SUM() Function Returns The Sum Of All The Values In A Set.
The Following Is The Syntax Of Sum Function.
• MIN FUNCTION:
The Min() Function Returns The Minimun Value Of A Set.
The Following Is The Syntax Of The Min Function:
MIN()

• MAX FUNCTION:
The Max() Function Returns The Maximum Value Of A Set.
The Following Is The Syntax Of The Max Function:
MAX()

• COUNT FUNCTION:
The Count Function Returns The Count Of The Set.
The Following Is The Syntax Of The Count Function.
• Let’s Create A Demo Database To Perform These Agregrate Functions.
SELECT * FROM STUDENTS
• CALCULATING AVERAGE OF FEES PAID

• CALCULATING SUM OF FEES PAID.

• CALCULATING COUNT OF FIRST_NAME.


• CALCULATING MINIMUM OF FEES_PAID.

• CALCULATING MAXIMUM OF FEES_PAID.


NULL VALUES
• A Field With A NULL Value Is A Field With No Value.
• A Null Value Is Different From A Zero Value Or A Field That Contains Spaces. A Field
With A NULL Value Is One That Has Been Left Blank During Record Creation!
• A Null Value In Sql Represents A Missing Or Unknown Value. It Is Not The Same As
Zero Or An Empty String, And It Cannot Be Compared To Any Other Value. The
Following Are Some Important Things To Know About Null Values In SQL.
• Null Values Can Be Checked Using The Is Null Or Is Not Null Operators In Sql.
• Example:
• CHECKING NULL VALUES:
IS NULL SYNTAX

IS NOT NULL SYNTAX


DATA DEFINATION
LANGUAGE
• Data Definition Language Actually Consists Of The SQL Commands That Can Be Used To
Define The Database Schema.

• It Simply Deals With Descriptions Of The Database Schema And Is Used To Create And Modify
The Structure Of Database Objects In The Database.

• Ddl Is A Set Of Sql Commands Used To Create, Modify, And Delete Database Structures But
Not Data. These Commands Are Normally Not Used By A General User, Who Should Be
Accessing The Database Via An Application.
LIST OF DDL
COMMANDS:
• CREATE: This Command Is Used To Create The Database Or Its Objects (Like Table, Index,
Function, Views, Store Procedure, And Triggers).
• DROP: This Command Is Used To Delete Objects From The Database.
• ALTER: This Is Used To Alter The Structure Of The Database.
• TRUNCATE: This Is Used To Remove All Records From A Table, Including All Spaces Allocated
For The Records Are Removed.
• COMMENT: This Is Used To Add Comments To The Data Dictionary.
• RENAME: This Is Used To Rename An Object Existing In The Database.

You might also like