Views in SQL, Data Defination Languge,
Views in SQL, Data Defination Languge,
• 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
• 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.
• 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
• 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.