sql online training|100%practical&live training

18
Database/SQL Overview

Upload: masood-khan

Post on 20-Jan-2015

546 views

Category:

Education


2 download

DESCRIPTION

This Course is designed by iTeknowledge.com experts to provide concrete and indepth knowledge of sql and pl/sql.More details : http://www.iteknowledge.com/oracle/sqlsql-pl-sql/

TRANSCRIPT

Page 1: sql online Training|100%Practical&Live Training

Database/SQL Overview

Page 2: sql online Training|100%Practical&Live Training

Outline

• What is Database• What is DBMS• What is Schema• What is SQL• SQL Queries• Database Objects• DataModelling/ ERD

Page 3: sql online Training|100%Practical&Live Training

Database

• A database is an organized collection of data. The data are typically organized in appropriate manner which allows to process the data in a easy way.

• Database management systems (DBMSs) are specially designed applications that interact with the user, other applications, and the database itself to capture and analyze data. A general-purpose database management system (DBMS) is a software system designed to allow the definition, creation, querying, update, and administration of databases.

Page 4: sql online Training|100%Practical&Live Training

What is Schema

• A schema is collection of database objects, including logical structures such as tables, views, sequences, stored procedures, synonyms, indexes, clusters, and database links, triggers, packages etc.

• A user owns a schema. • A user and a schema have the same name.

Page 5: sql online Training|100%Practical&Live Training

SQL

• SQL : Structured Query Language• SQL is a special purpose programming

language designed for managing data held in RDBMS

• SQL Consists of : DDL(Data Definition Language) , DML (Data Manipulation Language) and DCL(Data Control Language)

Page 6: sql online Training|100%Practical&Live Training

SQL Queries

• The Most important functionality of SQL query is to retrieve the data which is achieved using SELECT statement.

• Any SQL query will have : SELECT and FROM clause.

SELECT [column, ] group_function(column), ….FROM table[WHERE condition][GROUP BY column][HAVING group_condition][ORDER BY column] ;

Page 7: sql online Training|100%Practical&Live Training

SQL Clause’s• SELECT clause indicates which columns to be shown in the output.• FROM clause which indicates the tables from which data is to be retrieved.• WHERE clause includes a comparison operator, which restricts the rows

returned by the query. • GROUP BY clause is used to project rows having common values into a

smaller set of rows. GROUP BY is often used in conjunction with SQL aggregation functions or to eliminate duplicate rows from a result set. The WHERE clause is applied before the GROUP BY clause.

• HAVING clause includes a predicate used to filter rows resulting from the GROUP BY clause.

• ORDER BY clause identifies which columns are used to sort the resulting data, and in which direction they should be sorted (options are ascending or descending). Without an ORDER BY clause, the order of rows returned by an SQL query is undefined.

Page 8: sql online Training|100%Practical&Live Training

DDL• Data Definition Language (DDL) statements are used to define the database structure

or schema. Some examples:• CREATE - to create objects in the database• ALTER - alters the structure of the database• DROP - delete objects from the database• TRUNCATE - remove all records from a table, including all spaces allocated for the

records are removed• COMMENT - add comments to the data dictionary• RENAME - rename an object…• FLASHBACK ... (All statements beginning with FLASHBACK)• GRANT• NOAUDIT• PURGE• RENAME• REVOKE

Page 9: sql online Training|100%Practical&Live Training

DMLData Manipulation Language (DML) statements are used for managing data within

schema objects. Some examples:• SELECT - retrieve data from the a database The SELECT statement is a limited form of DML statement in that it can only

access data in the database. It cannot manipulate data stored in the database, although it can manipulate the accessed data before returning the results of the query.

• INSERT - insert data into a table• UPDATE - updates existing data within a table• DELETE - deletes all records from a table, the space for the records remain• MERGE - UPSERT operation (insert or update)• CALL - call a PL/SQL or Java subprogram• EXPLAIN PLAN - explain access path to data• LOCK TABLE - control concurrency

Page 10: sql online Training|100%Practical&Live Training

DCL

• The Data Control Language (DCL) authorizes users to access and manipulate data. Its two main statements are

• GRANT authorizes one or more users to perform an operation or a set of operations on an object.

• REVOKE eliminates a grant, which may be the default grant

Page 11: sql online Training|100%Practical&Live Training

TCL

• Transaction control statements manage changes made by DML statements. The transaction control statements are:

• COMMIT• ROLLBACK• SAVEPOINT• SET TRANSACTION• SET CONSTRAINT

Page 12: sql online Training|100%Practical&Live Training

What is a Join?

• A join is a query that combines rows from two or more tables, views, or materialized views.

• Oracle performs a join whenever multiple tables appear in the query's FROM clause. The query's select list can select any columns from any of these tables.

• If any two of these tables have a column name in common, you must qualify all references to these columns throughout the query with table names to avoid ambiguity.

Page 13: sql online Training|100%Practical&Live Training

Joins (Cont)

• Inner Join • Equi join • Natural Join• Cross Join

• Outer Join • Left Outer Join• Right Outer Join• Full Outer Join

• Self Join • Cross Join • Join using MULTIPLE TABLES

Page 14: sql online Training|100%Practical&Live Training

SingleRow/MultiRow(Group) Function

• Single row functions : Operate on single rows only and return one result per row .

• Different Types of Single row functions are – Character : UPPER, LOWER– Number : MOD– Date Conversion : TO_DATE– General :NVL, NVL2, NULLIF

• Multiple row functions: Manipulates groups of rows to give one result per group of rows.

• Also called as group functions• Ex: COUNT, MAX, MIN

Page 15: sql online Training|100%Practical&Live Training

Hierarchical Queries

• Hierarchical queries retrieve data based on a natural hierarchical relationship between rows in a table.

• Use tree walking to construct a hierarchy• Syntax :

SELECT [LEVEL], column, expr …FROM table[WHERE condition(s) ][START WITH conditions(s) ][CONNECT BY PRIOR condition(s) ] ;

Page 16: sql online Training|100%Practical&Live Training

Database Objects

• Tables (Normal), Global Temporary Table• Views(Simple, Complex), Materialized View• Indexes, Constraints, Sequence• Synonym• Procedure, Function, Package• Triggers• Schema

Page 17: sql online Training|100%Practical&Live Training

Data Modelling / ERD

Page 18: sql online Training|100%Practical&Live Training

1Basic SQL Statement, SELECT,FROM Clause

2 Sorting : ORDER BY , WHERE Clause

3 Single Row Function

4 Multiple Tables Data - Joins

5 Group Functions - GROUP BY Clause

6 Sub Queries

7 Manipulating data

8 Create tables

9 Constraints (PK,FK, UK)

10 Views , Materialized Views

11 Indexes

12 User Access

13 Datetime

14 SET Operators

15 Hierarchial Table Design, Query

16 Database Architecture

17ERD Concepts & Data Modelling Using SQL Data Modeller

18 Tables Vs Global Temporary Table

19 DBMS Scheduller

20 WRAPPER Utility

SQL Course Content