SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
2011

ANKUR
                                                   Contacts: www.poetrypoem.com/ankur

                                                             www.facebook.com/eminemankur

                                                   E-mail: rainaankur92@gmail.com

                                                   Phone: 9813269824




RAINA




[ORACLE DATABASE
PRESENTATION FOR THE
BASIC SQL UNDERSTANDING]
All the rights are reserved with the author. No part of this publication may be changed in any form
without the prior permission of the author. Copyright 2011
CONTENTS
   1. Introduction to Oracle RDBMS                                3
       1.1.Features                                               3
       1.2.Oracle Internet Platform                               4

   2. E.F.Codd’s Rules                                            5
      2.1 Rules                                                   5
      2.2 Satisfied by Oracle RDBMS                               6

   3. Oracle Database Architecture                                8
        3.1. The Database                                         9
        3.2. The Instance                                         11

   4. SQL Statements                                              14
       4.1.Types                                                  14
       4.2. Capabilities of SQL SELECT Statements                 15
       4.3.Data Retrieval Using SELECT Statement                  15
       4.4.Defining a NULL value                                  16
       4.5.Defining a Column Alias                                17
       4.6.Restricting and Sorting Statements                     17

   5. Using Single Row Functions To Customize Output              18
       5.1.   Features                                            22
       5.2.   General Functions                                   22
       5.3.   CASE Expression                                     24
       5.4.   DECODE Function                                     25

   6. Reporting Aggregating Data Using Group Functions            26
      6.1. Group Function                                         26
      6.2. Creating Groups of Data: GROUP BY clause syntax        27
      6.3. Using GROUP BY clause for multiple columns             28
      6.4. Restricting Group Results by HAVING clause             28


   7. Displaying Data From Multiple Tables                        29
      7.1     Using Subqueries to Solve Queries                   30




ANKUR RAINA                                                  09-IT-4505
8. Manipulating Data                           31
      8.1. INSERT statement                       31
      8.2. UPDATE statement                       32
      8.3. DELETE statement                       32
       8.4. TRUNCATE statement                    32


   9. Database Objects                            34
       9.1. CREATE statement                      34
       9.2. CREATE TABLE using a sub-query        35
       9.3. Dropping a table                      35

   10.Creating Other Schema Objects               36
      10.1. Views                                 36
      10.2.Creating views                         36
      10.3.Sequence                               37
      10.4.Indexes                                37
      10.5.Synonyms                               38

   11.References                                  39




ANKUR RAINA                                  09-IT-4505
CHAPTER 1

  “Our goal is very simply to become the desktop for e-businesses - Larry Ellison”
Introduction to Oracle RDBMS

The Oracle Database (commonly referred to as Oracle RDBMS or simply as Oracle) is an
object-relational database management system (ORDBMS) produced and marketed by
Oracle Corporation. Larry Ellison and his friends and former co-workers Bob Miner and Ed
Oates started the consultancy Software Development Laboratories (SDL) in 1977. SDL
developed the original version of the Oracle software. The name Oracle comes from the
code-name of a CIA-funded project Ellison had worked on while previously employed by
Ampex. The latest release of Oracle RDBMS is 11g Release 2.

Features:-




ANKUR RAINA                                                                   09-IT-4505
Oracle Internet Platform

     The Oracle products provide all the necessary components to develop an application.
     The integrated Oracle Internet Platform includes everything needed to develop,
     deploy, and manage internet applications, including these three core pieces:
     1. Browser-based clients to process presentation
     2. Application servers to execute business logic and serve presentation logic to
        browser-based clients
     3. Databases to execute database-intensive business logic and serve data




ANKUR RAINA                                                                    09-IT-4505
CHAPTER 2

E.F.Codd’s Rules


E.F. Codd, the famous mathematician has introduced 12 rules for the relational model for
databases commonly known as Codd's rules. The rules mainly define what is required for a
DBMS for it to be considered relational, i.e., an RDBMS. There is also one more rule i.e.
Rule00 which specifies the relational model should use the relational way to manage the
database. The rules and their description are as follows:-

Rules:
Rule 000: Zeroth rule:

An RDBMS system should be capable of using its relational facilities (exclusively) to manage
the database.

Rule 1: The information rule:

All information in the database is to be represented in one and only one way. This is
achieved by values in column positions within rows of tables.

Rule 2: The guaranteed access rule:

All data must be accessible with no ambiguity. This is achieved in the RDBMS by using the
primary key concept.

Rule 3: Systematic treatment of null values:

The DBMS must allow each field to remain null. The null can be stored in any field of any
datatype.

Rule 4: Active online catalog based on the relational model:

The authorized users can access the database structure by using common language i.e. SQL.

Rule 5: The comprehensive data sublanguage rule:

The system must support at least one relational language that has simple syntax and
transaction management facilities. It can be used in the application as well as in the RDBMS
systems.




ANKUR RAINA                                                                        09-IT-4505
Rule 6: The view updating rule:

All views must be updatable by the system.



Rule 7: High-level insert, update, and delete:

The system is able to insert, update and delete operations fully. It can also perform the
operations on multiple rows simultaneously.

Rule 8: Physical data independence:

Changes to the physical storage structure must not require a change to an application
based on the structure.

Rule 9: Logical data independence:

Changes to the logical level (tables, columns, rows, and so on) must not require a change to
an application based on the structure.

Rule 11: Distribution independence:

The distribution of portions of the database to various locations should be invisible to users
of the database.

Rule 12: The non- subversion rule:

If the system provides a low-level (record-at-a-time) interface, then that interface cannot be
used to subvert the system, for example, bypassing a relational security or integrity
constraint.

Note:- Any database management system which fulfills 6 or more than 6 rules can be
considered as the RDBMS.

Rules satisfied by Oracle RDBMS


Oracle RDBMS follows 11 out of 12 rules. One rule which is not followed is debatable.

   1. View Updating Rule:

       It is because, according to Dr. E.F.Codd, every view should support full range of data
       manipulation, but in Oracle, it is not feasible for complex views based on multiple
       tables.




ANKUR RAINA                                                                          09-IT-4505
2. Systematic Treatment of Null value

      Null in Oracle is treated as absence of a value or unknown status ( in case of
      comparison of values ) and it does not have any systematic representation. In Oracle,
      no two null values are equal (as this will return a value which is treated as unknown
      by Oracle). If there is a systematic representation, then NULL value must be
      comparable.




ANKUR RAINA                                                                      09-IT-4505
CHAPTER 3

Oracle Database Architecture
The Oracle RDBMS consists of two main components:-

     1. The Database or the Physical Structures
     2. The Instance or the Memory Structures




Control Files:

These files contain data about the database itself, called the metadata. These files are
critical to the database. Without them, one cannot open the data files to access the data
within the database.

Data Files:

These files contain the data of the database.




ANKUR RAINA                                                                        09-IT-4505
Online Redo Log Files:

These files allow for instance recovery of the database. If the database were to crash and
not lose data files, the instance will be able to recover the database with the information in
these files.




Tablespaces and Data Files:




ANKUR RAINA                                                                          09-IT-4505
A database is divided into logical storage units called tablespaces, which can be used to
group related logical structures. Each database is logically divided into one or more
tablespaces. One or more data files are explicitly created for each tablespace to physically
store the data of all logical structures in a tablespace.

Segments, Extents, and Blocks:

Database objects such as tables and indexes are stored in tablespaces as segments. Each
segment contains one or more extents. An extent consists of contiguous data blocks, which
means that each extent can exist only in one data file. Data blocks are the smallest units of
I/O in the database.




When the database requests a set of data blocks from the operating system (OS), the OS
maps this to the actual OS block on the storage device. Because of this, one needs not to be
aware of the physical address of any data in the database. This also means that a data file
can be striped and or mirrored on several disks.

The size of the data block can be set at database creation time. The default size of 8K is
adequate for more databases. If your database supports a data warehouse application that
has large tables and indexes, then a larger block may be beneficial. If your database
supports a transactional application where reads and writes are very random, then a smaller
block size may be beneficial. The maximum block size is dependent on the OS. The minimum
block size is 2K and should rarely (if ever) be used.

There are other files that are not officially part of the database, but are important to the
successful running of the database. These are:

Parameter File:

The parameter file is used to define how the instance will be configured when it starts up.




ANKUR RAINA                                                                           09-IT-4505
Password File:

This file allows users to connect remotely to the database and perform administrative tasks.

Archive Log Files:

These files contain an ongoing history of the redo generated by the instance. These files
allow for database recovery. By using these files and a backup of the database, it is possible
to recover a lost file.

Oracle Instance Management




An Oracle Database server consists of an Oracle Database and an Oracle instance. An Oracle
instance consists of memory buffers known as the System Global Area (SGA) and
background processes.

The instance is idle (non-existent) until it is started. When the instance is started, an
initialization parameter file is read and the instance is configured accordingly.

After the instance is started and the database is opened, users can access the database.




ANKUR RAINA                                                                            09-IT-4505
Oracle Memory Structures
The basic memory structures associated with an Oracle instance include:

System Global Area (SGA):
It is shared by all server and background processes.

Program Global Area (PGA):
It is private to each server and background process; there is one PGA for each process.



The SGA is a shared memory area that contains data and control information for the
instance. The SGA consists of the following data structures:

Database buffer cache: Caches blocks of data retrieved from the database.

Redo log buffer: Caches redo information (used for instance recovery) until it can be written
to the physical redo log files stored on disk.

Shared pool: Caches various constructs that can be shared among users.

Large pool: Is an optional area used for buffering large I/O requests.

Java pool: Is used for all session-specific Java code and data within the Java Virtual Machine
(JVM).


ANKUR RAINA                                                                         09-IT-4505
Stream pool: Is used by Oracle Streams.

When we start the instance by using Enterprise Manager or SQL*Plus, the memory allocated
for the SGA is displayed.

A PGA is a memory region that contains data and control information for each server
process. A server process services a client’s requests. Each server process has its own
private PGA area that is created when the server process is started. Access to it is exclusive
to that is created when the server process is started. Access to it is exclusive to that server
process, and is read and written only by the oracle code acting on behalf of it.

The amount of PGA memory used and its content depends on whether the instance is
configured in shared mode. Generally, the PGA contains the following:

Private SQL area: Contains data such as bind information and run-time memory
structures. Each session that issues a SQL statement has a private SQL area.

Session memory: Is memory allocated to hold session variables and other information
related to the session.




ANKUR RAINA                                                                           09-IT-4505
CHAPTER 4

SQL Statements
SQL stand for Structured Query Language. SQL has become the de-facto standard language
used for creating and querying relational databases. The SQL statements can be categorized
as:-

Types of SQL Statements:

Data Manipulation Language:
It constitutes those commands which are used to maintain & query a database, including
updating, inserting, modifying and querying data.

SELECT

INSERT

UPDATE

DELETE

MERGE

Data Definition Language:
It constitutes those commands which are used to define a database including creating,
altering and dropping tables and establishing constraints.

CREATE

ALTER

DROP

RENAME

TRUNCATE

COMMENT

Data Control Language:
It controls a database and deals with the administrative privileges.

GRANT

REVOKE



ANKUR RAINA                                                                      09-IT-4505
Transaction Control:
A discrete unit of work that must be completely processed or not processed at all within a
computer system is called a transaction. The following commands control the transactions.

COMMIT

ROLLBACK

SAVEPOINT

Capabilities of SQL SELECT statements:

The three basic capabilities of SELECT statements are:

Projection: To choose the columns in a table that is returned by a query.

Selection: To choose the rows in a table that is returned by a query. Various criteria can be
used to restrict the rows that are retrieved.

Joining: To bring together data that is stored in different tables by specifying the link
between them.

Data Retrieval: Using SELECT Statement:




SELECT identifies the columns to be displayed.

FROM identifies the table containing those columns.




If all columns are of data in a table are to be listed, an asterisk (*) can be used.


ANKUR RAINA                                                                            09-IT-4505
Defining a NULL value:
A null is a value that is unavailable, unassigned, unknown, or inapplicable. A null is not the
same as a zero. Columns of any data type can contain nulls. However, some constraints
(NOT NULL and PRIMARY KEY) prevent nulls from being used in the column.




...

Arithmetic expressions containing a null value evaluate to null.




...




ANKUR RAINA                                                                           09-IT-4505
Defining a Column Alias:
A column alias is used to rename a column heading. It is useful with calculations. It either
follows the column name or an optional AS keyword is used between the column name and
alias. If the alias name is case sensitive, enclose it in double-quotation marks.




Restricting Rows: Using WHERE clause:

WHERE restricts the query to rows that meet a condition

Condition is composed of column names, expressions, constants, and a comparison operator.




Character Strings and Dates:

Character strings and date values are enclosed in single quotation marks. Character strings
are case sensitive, and date values are format sensitive. The default date format is
DD-MON-RR.




ANKUR RAINA                                                                        09-IT-4505
Comparison Conditions:




ANKUR RAINA              09-IT-4505
Logical Conditions:




ANKUR RAINA           09-IT-4505
Rules of Precedence




Sorting Data:
Sort retrieved rows with the ORDER BY clause:

   1. ASC: ascending order, default
   2. DESC: descending order
      The ORDER BY clause comes last in the SELECT statement.




ANKUR RAINA                                                     09-IT-4505
Using Substitution Variables:
Substitution variables are used to temporarily store values with a single-ampersand (&) and
double-ampersand (&&) substitution. Substitution variables are used to supplement the
following:

   1.   WHERE clause
   2.   ORDER BY clause
   3.   Column expressions
   4.   Table names
   5.   Entire SELECT statements




   Use the double ampersand (&&) if you want to reuse the variable value without
   prompting the user each time.




ANKUR RAINA                                                                       09-IT-4505
CHAPTER 5

   Using Single Row Functions to Customize Output:
   Features:

   1.   Used to manipulate data items
   2.   Accept arguments and return one value
   3.   Act on each row that is returned
   4.   Return one result per row
   5.   May modify the data type
   6.   Can be nested
   7.   Accept arguments that can be a column or an expression

   General Functions:

FUNCTION                    SYNTAX                          DESCRIPTION

                                                    Converts a null value to actual
   NVL                NVL(expr1,expr2)              value.

                                         I f expr1 is not null, NVL2
  NVL2            NVL2(expr1,expr2,expr3)returns expr2. If expr1 is null,
                                         NVL2 returns expr3.
                                         Compares two expressions
 NULLIF                                  and returns null if they are
               NULLIF(expr1,expr2)       equal; returns the first
                                         expression if they are not
                                         equal.
                                         Returns the first non-null
COALESCE COALESCE(expr1,expr2,...,exprn) expression in the expression
                                         list.




ANKUR RAINA                                                              09-IT-4505
USING NVL:




   USING NVL2:




   USING NULLIF:




   USING COALESCE:




ANKUR RAINA          09-IT-4505
CASE Expression:

   It facilitates conditional inquiries by doing the work of an IF-THEN_ELSE statement.




ANKUR RAINA                                                                        09-IT-4505
DECODE Function:

   It facilitates conditional inquiries by doing the work of a CASE expression or
   IF-THEN-ELSE statement.




ANKUR RAINA                                                                         09-IT-4505
CHAPTER 6

   Reporting Aggregated Data Using Group Functions:
   Group Functions:
   Group functions operate on sets of rows to give one result per row.

   Types of Group functions are:



   FUNCTION                        SYNTAX                                DESCRIPTION

   AVG           AVG([DISTINCT|ALL]n)          Average value of n, ignoring null
                                               values.
   COUNT         COUNT({*|[DISTINCT|ALL]expr}) No. of rows where expr
                                               evaluates to something other
                                               than null(count all selected
                                               rows using * , including
                                               duplicates and rows with nulls)
   MAX           MAX([DISTINCT|ALL]expr)       Max value of expr ignoring null
                                               values
   MIN           MIN([DISTINCT|ALL]expr)       Min value of expr ignoring null
                                               values
   STDDEV        STDDEV([DISTINCT|ALL]x)       Standard deviation of n ignoring
                                               null values
   SUM           SUM([DISTINCT|ALL]n)          Sum values of n ignoring null
                                               values
   VARIANCE      VARIANCE([DISTINCT|ALL]x)     Variance of n ignoring null
                                               values




   COUNT (*) returns the number of rows in a table.




ANKUR RAINA                                                                     09-IT-4505
COUNT (expr) returns the number of rows with non-null values for expr.




   COUNT (DISTINCT expr) returns the number of distinct non-null values of expr.




   Creating Groups of Data: GROUP BY Clause Syntax




ANKUR RAINA                                                                 09-IT-4505
Using GROUP BY clause on multiple columns




   Restricting Group Results with HAVING clause:
   When you use the HAVING clause, the Oracle Server restricts groups as follows:

   1. Rows are grouped
   2. The group function is applied
   3. Groups matching the HAVING clause are displayed.




ANKUR RAINA                                                                     09-IT-4505
CHAPTER 7

Displaying Data Using Multiple Tables




      Creating Natural Joins:
      The NATURAL JOIN clause is based on all columns in the two tables that have the
      same name. It selects rows from the two tables that have equal values in all matched
      columns. If the columns having the same names have different data types, an error is
      returned.




      If several columns have the same names but the data types do not match, natural
      join can be applied by using the USING clause to specify the columns that should
      be used for an equijoin. Use the USING clause to match only one column when
      more than one column matches. Table name or alias is not used in the referenced
      columns.




ANKUR RAINA                                                                     09-IT-4505
Using Sub-Queries to Solve Queries:
      Sub-Query:
      A query within a query is known as a sub-query. A sub-query executes once before
      the main query. The result of sub-query is used by the main query.




ANKUR RAINA                                                                    09-IT-4505
CHAPTER 8

Manipulating Data:
       A Data Manipulation language (DML) statement is executed when you:
           Add new rows to a table
           Modify existing rows in a table
           Remove existing rows from a table
              A transaction consists of a collection of DML statements that form a logical
              unit of work.

INSERT Statement:

        Syntax:




              Implicit Method: omit the column from the column list.




              Explicit Method: Specify the NULL keyword in values clause.




UPDATE Statement:

UPDATE statement is used to modify the existing rows in a table. More than one row can be
updated at a time (if required).




ANKUR RAINA                                                                        09-IT-4505
DELETE Statement:

DELETE Statement is used to remove existing rows from a table.




If one omits the WHERE clause, all the rows from the table will be deleted.




TRUNCATE Statement:

The TRUNCATE Statement removes all rows from a table, leaving the table empty and the
table structure intact. It is a Data Definition Language (DDL) statement rather than a DML
statement; cannot easily be undone.




ANKUR RAINA                                                                        09-IT-4505
ANKUR RAINA   09-IT-4505
CHAPTER 9

Database Objects:




CREATE Statement:




ANKUR RAINA                     09-IT-4505
CREATE TABLE using a Sub-Query:




Dropping a Table:

      All data and structure in the table are deleted.
      Any pending transactions are committed.
      All indexes are dropped.
      All constraints are dropped.
      You cannot roll back the DROP TABLE statement.




ANKUR RAINA                                               09-IT-4505
Creating Other Schema Objects:
Views:

      To restrict data access.
      To make complex queries easy.
      To provide data independence.
      To present different views of the same data.




CREATE VIEW Syntax (simple view):




CREATE VIEW (complex view):




ANKUR RAINA                                           09-IT-4505
You cannot modify data in a view if it contains:

      Group functions
      A GROUP BY clause
      The DISTINCT keyword
      The pseudo column ROWNUM keyword
      Columns defined by expressions

You cannot add data in a view if following conditions along with conditions above prevail:

      NOT NULL columns in the base tables that are not selected by the view.

Sequences:
A sequence

      Can automatically generate unique numbers
      Is a sharable object
      Can be used to create a primary key value
      Replaces application code
      Speeds up the efficiency of accessing sequence values when cached in memory




Indexes:
An index:

      Is a schema object
      Can be used by the Oracle server to speed up the retrieval of rows by using a pointer
      Can reduce disk I/O by using a path access method to locate data quickly
      Is independent of the table that it indexes
      Is used and maintained automatically by the Oracle server


ANKUR RAINA                                                                        09-IT-4505
Indexes are created in the following two ways:

         Automatically: A unique index is created automatically when you define a PRIMARY
          KEY or UNIQUE constraint in a table definition.
         Manually: Users can create non-unique indexes on columns to speed up access to
          the rows.



Syntax:




Synonyms:
Simplify access to objects by creating a synonym (another name for an object). With
synonyms, we can:

         Create an easier reference to a table that is owned by another user
         Shorten lengthy object names




ANKUR RAINA                                                                      09-IT-4505
REFERENCES


      Web Resources

    http://wiki.answers.com/Q/What_are_EF_
     Codd_rules

    www.oracle.com


    www.wikipedia.com


    www.oraclecoach.com




      Books:

    Study material by Oracle University
     Press


    Modern Database Management by Jeffrey
     A. Hoffer, Mary B. Prescott and Fred
     R. McFadden




ANKUR RAINA                           09-IT-4505

Mais conteúdo relacionado

Mais procurados

Toc d17090 gc30
Toc d17090 gc30Toc d17090 gc30
Toc d17090 gc30Imran Ali
 
ORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAININGORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAININGSanthosh Sap
 
MOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical ExamplesMOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical ExamplesMonica Li
 
oracle-rest-data-service-instal-config
oracle-rest-data-service-instal-configoracle-rest-data-service-instal-config
oracle-rest-data-service-instal-confighunghtc83
 
SharePoint 2010 High Availability - TechEd Brasil 2010
SharePoint 2010 High Availability - TechEd Brasil 2010SharePoint 2010 High Availability - TechEd Brasil 2010
SharePoint 2010 High Availability - TechEd Brasil 2010Michael Noel
 
configuring+oracle+rds+with+glasfish+server
configuring+oracle+rds+with+glasfish+serverconfiguring+oracle+rds+with+glasfish+server
configuring+oracle+rds+with+glasfish+serverhunghtc83
 
SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...
SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...
SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...Michael Noel
 
Infrastructure Planning and Design
Infrastructure Planning and DesignInfrastructure Planning and Design
Infrastructure Planning and DesignSergi Duró
 
MOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX ApplicationsMOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX ApplicationsMonica Li
 
Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2Otto Paiz
 
What's new in Oracle 19c & 18c Recovery Manager (RMAN)
What's new in Oracle 19c & 18c Recovery Manager (RMAN)What's new in Oracle 19c & 18c Recovery Manager (RMAN)
What's new in Oracle 19c & 18c Recovery Manager (RMAN)Satishbabu Gunukula
 
Twp partitioning-11gr2-2009-09-130569
Twp partitioning-11gr2-2009-09-130569Twp partitioning-11gr2-2009-09-130569
Twp partitioning-11gr2-2009-09-130569Naga Mallesh K
 
oracle 9i cheat sheet
oracle 9i cheat sheetoracle 9i cheat sheet
oracle 9i cheat sheetPiyush Mittal
 

Mais procurados (20)

Toc d17090 gc30
Toc d17090 gc30Toc d17090 gc30
Toc d17090 gc30
 
201 Pdfsam
201 Pdfsam201 Pdfsam
201 Pdfsam
 
ORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAININGORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAINING
 
Ramesh_Oracle_DBA
Ramesh_Oracle_DBARamesh_Oracle_DBA
Ramesh_Oracle_DBA
 
MOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical ExamplesMOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical Examples
 
oracle-rest-data-service-instal-config
oracle-rest-data-service-instal-configoracle-rest-data-service-instal-config
oracle-rest-data-service-instal-config
 
SharePoint 2010 High Availability - TechEd Brasil 2010
SharePoint 2010 High Availability - TechEd Brasil 2010SharePoint 2010 High Availability - TechEd Brasil 2010
SharePoint 2010 High Availability - TechEd Brasil 2010
 
configuring+oracle+rds+with+glasfish+server
configuring+oracle+rds+with+glasfish+serverconfiguring+oracle+rds+with+glasfish+server
configuring+oracle+rds+with+glasfish+server
 
SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...
SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...
SharePoint 2010 High Availability and Disaster Recovery - SharePoint Connecti...
 
Less05 Network
Less05 NetworkLess05 Network
Less05 Network
 
Oracle Complete Interview Questions
Oracle Complete Interview QuestionsOracle Complete Interview Questions
Oracle Complete Interview Questions
 
Infrastructure Planning and Design
Infrastructure Planning and DesignInfrastructure Planning and Design
Infrastructure Planning and Design
 
Oracle11g notes
Oracle11g notesOracle11g notes
Oracle11g notes
 
MOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX ApplicationsMOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX Applications
 
ora_sothea
ora_sotheaora_sothea
ora_sothea
 
Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2
 
What's new in Oracle 19c & 18c Recovery Manager (RMAN)
What's new in Oracle 19c & 18c Recovery Manager (RMAN)What's new in Oracle 19c & 18c Recovery Manager (RMAN)
What's new in Oracle 19c & 18c Recovery Manager (RMAN)
 
Twp partitioning-11gr2-2009-09-130569
Twp partitioning-11gr2-2009-09-130569Twp partitioning-11gr2-2009-09-130569
Twp partitioning-11gr2-2009-09-130569
 
oracle 9i cheat sheet
oracle 9i cheat sheetoracle 9i cheat sheet
oracle 9i cheat sheet
 
21
2121
21
 

Destaque

Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle SqlAhmed Yaseen
 
Oracle 10g sql fundamentals i
Oracle 10g sql fundamentals iOracle 10g sql fundamentals i
Oracle 10g sql fundamentals iManaswi Sharma
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorialMohd Tousif
 
Présentation Oracle DataBase 11g
Présentation Oracle DataBase 11gPrésentation Oracle DataBase 11g
Présentation Oracle DataBase 11gCynapsys It Hotspot
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsqlSid Xing
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals INick Buytaert
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands1keydata
 

Destaque (10)

Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle Sql
 
Oracle 10g sql fundamentals i
Oracle 10g sql fundamentals iOracle 10g sql fundamentals i
Oracle 10g sql fundamentals i
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
Présentation Oracle DataBase 11g
Présentation Oracle DataBase 11gPrésentation Oracle DataBase 11g
Présentation Oracle DataBase 11g
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsql
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 

Semelhante a Oracle SQL Basics by Ankur Raina

Sql server difference faqs- 5
Sql server difference faqs-  5Sql server difference faqs-  5
Sql server difference faqs- 5Umar Ali
 
Sql a practical_introduction
Sql a practical_introductionSql a practical_introduction
Sql a practical_introductioninvestnow
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introductionHasan Kata
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introductionsanjaychauhan689
 
Oracle DBA Tutorial for Beginners -Oracle training institute in bangalore
Oracle DBA Tutorial for Beginners -Oracle training institute in bangaloreOracle DBA Tutorial for Beginners -Oracle training institute in bangalore
Oracle DBA Tutorial for Beginners -Oracle training institute in bangaloreTIB Academy
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Databasepuja_dhar
 
Oracle database 12c intro
Oracle database 12c introOracle database 12c intro
Oracle database 12c intropasalapudi
 
Oracle no sql database bigdata
Oracle no sql database   bigdataOracle no sql database   bigdata
Oracle no sql database bigdataJoão Gabriel Lima
 
My sql crashcourse_2012
My sql crashcourse_2012My sql crashcourse_2012
My sql crashcourse_2012sqlhjalp
 
Solving performance problems in MySQL without denormalization
Solving performance problems in MySQL without denormalizationSolving performance problems in MySQL without denormalization
Solving performance problems in MySQL without denormalizationdmcfarlane
 
Akiban Technologies: Renormalize
Akiban Technologies: RenormalizeAkiban Technologies: Renormalize
Akiban Technologies: RenormalizeAriel Weil
 
Akiban Technologies: Renormalize
Akiban Technologies: RenormalizeAkiban Technologies: Renormalize
Akiban Technologies: RenormalizeAriel Weil
 
Overview of oracle database
Overview of oracle databaseOverview of oracle database
Overview of oracle databaseSamar Prasad
 
Overview of oracle database
Overview of oracle databaseOverview of oracle database
Overview of oracle databaseSamar Prasad
 

Semelhante a Oracle SQL Basics by Ankur Raina (20)

Sql server difference faqs- 5
Sql server difference faqs-  5Sql server difference faqs-  5
Sql server difference faqs- 5
 
Sql a practical_introduction
Sql a practical_introductionSql a practical_introduction
Sql a practical_introduction
 
10g sql e book
10g sql e book10g sql e book
10g sql e book
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introduction
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introduction
 
Oracle DBA Tutorial for Beginners -Oracle training institute in bangalore
Oracle DBA Tutorial for Beginners -Oracle training institute in bangaloreOracle DBA Tutorial for Beginners -Oracle training institute in bangalore
Oracle DBA Tutorial for Beginners -Oracle training institute in bangalore
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Database
 
Oracle SQL Part1
Oracle SQL Part1Oracle SQL Part1
Oracle SQL Part1
 
NoSQL Consepts
NoSQL ConseptsNoSQL Consepts
NoSQL Consepts
 
orical
oricalorical
orical
 
Oracle database 12c intro
Oracle database 12c introOracle database 12c intro
Oracle database 12c intro
 
Oracle no sql database bigdata
Oracle no sql database   bigdataOracle no sql database   bigdata
Oracle no sql database bigdata
 
NoSQL
NoSQLNoSQL
NoSQL
 
My sql crashcourse_2012
My sql crashcourse_2012My sql crashcourse_2012
My sql crashcourse_2012
 
Solving performance problems in MySQL without denormalization
Solving performance problems in MySQL without denormalizationSolving performance problems in MySQL without denormalization
Solving performance problems in MySQL without denormalization
 
Akiban Technologies: Renormalize
Akiban Technologies: RenormalizeAkiban Technologies: Renormalize
Akiban Technologies: Renormalize
 
Akiban Technologies: Renormalize
Akiban Technologies: RenormalizeAkiban Technologies: Renormalize
Akiban Technologies: Renormalize
 
Overview of oracle database
Overview of oracle databaseOverview of oracle database
Overview of oracle database
 
Overview of oracle database
Overview of oracle databaseOverview of oracle database
Overview of oracle database
 
Oracle 12c
Oracle 12cOracle 12c
Oracle 12c
 

Mais de Ankur Raina

Introduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUWIntroduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUWAnkur Raina
 
PyMongo for PyCon First Draft
PyMongo for PyCon First DraftPyMongo for PyCon First Draft
PyMongo for PyCon First DraftAnkur Raina
 
Ankur py mongo.pptx
Ankur py mongo.pptxAnkur py mongo.pptx
Ankur py mongo.pptxAnkur Raina
 
Sql project presentation
Sql project presentationSql project presentation
Sql project presentationAnkur Raina
 

Mais de Ankur Raina (8)

Introduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUWIntroduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUW
 
PyMongo for PyCon First Draft
PyMongo for PyCon First DraftPyMongo for PyCon First Draft
PyMongo for PyCon First Draft
 
Mug17 gurgaon
Mug17 gurgaonMug17 gurgaon
Mug17 gurgaon
 
Ankur py mongo.pptx
Ankur py mongo.pptxAnkur py mongo.pptx
Ankur py mongo.pptx
 
E
EE
E
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Sql project presentation
Sql project presentationSql project presentation
Sql project presentation
 
Big data
Big dataBig data
Big data
 

Último

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Oracle SQL Basics by Ankur Raina

  • 1. 2011 ANKUR Contacts: www.poetrypoem.com/ankur www.facebook.com/eminemankur E-mail: rainaankur92@gmail.com Phone: 9813269824 RAINA [ORACLE DATABASE PRESENTATION FOR THE BASIC SQL UNDERSTANDING] All the rights are reserved with the author. No part of this publication may be changed in any form without the prior permission of the author. Copyright 2011
  • 2. CONTENTS 1. Introduction to Oracle RDBMS 3 1.1.Features 3 1.2.Oracle Internet Platform 4 2. E.F.Codd’s Rules 5 2.1 Rules 5 2.2 Satisfied by Oracle RDBMS 6 3. Oracle Database Architecture 8 3.1. The Database 9 3.2. The Instance 11 4. SQL Statements 14 4.1.Types 14 4.2. Capabilities of SQL SELECT Statements 15 4.3.Data Retrieval Using SELECT Statement 15 4.4.Defining a NULL value 16 4.5.Defining a Column Alias 17 4.6.Restricting and Sorting Statements 17 5. Using Single Row Functions To Customize Output 18 5.1. Features 22 5.2. General Functions 22 5.3. CASE Expression 24 5.4. DECODE Function 25 6. Reporting Aggregating Data Using Group Functions 26 6.1. Group Function 26 6.2. Creating Groups of Data: GROUP BY clause syntax 27 6.3. Using GROUP BY clause for multiple columns 28 6.4. Restricting Group Results by HAVING clause 28 7. Displaying Data From Multiple Tables 29 7.1 Using Subqueries to Solve Queries 30 ANKUR RAINA 09-IT-4505
  • 3. 8. Manipulating Data 31 8.1. INSERT statement 31 8.2. UPDATE statement 32 8.3. DELETE statement 32 8.4. TRUNCATE statement 32 9. Database Objects 34 9.1. CREATE statement 34 9.2. CREATE TABLE using a sub-query 35 9.3. Dropping a table 35 10.Creating Other Schema Objects 36 10.1. Views 36 10.2.Creating views 36 10.3.Sequence 37 10.4.Indexes 37 10.5.Synonyms 38 11.References 39 ANKUR RAINA 09-IT-4505
  • 4. CHAPTER 1 “Our goal is very simply to become the desktop for e-businesses - Larry Ellison” Introduction to Oracle RDBMS The Oracle Database (commonly referred to as Oracle RDBMS or simply as Oracle) is an object-relational database management system (ORDBMS) produced and marketed by Oracle Corporation. Larry Ellison and his friends and former co-workers Bob Miner and Ed Oates started the consultancy Software Development Laboratories (SDL) in 1977. SDL developed the original version of the Oracle software. The name Oracle comes from the code-name of a CIA-funded project Ellison had worked on while previously employed by Ampex. The latest release of Oracle RDBMS is 11g Release 2. Features:- ANKUR RAINA 09-IT-4505
  • 5. Oracle Internet Platform The Oracle products provide all the necessary components to develop an application. The integrated Oracle Internet Platform includes everything needed to develop, deploy, and manage internet applications, including these three core pieces: 1. Browser-based clients to process presentation 2. Application servers to execute business logic and serve presentation logic to browser-based clients 3. Databases to execute database-intensive business logic and serve data ANKUR RAINA 09-IT-4505
  • 6. CHAPTER 2 E.F.Codd’s Rules E.F. Codd, the famous mathematician has introduced 12 rules for the relational model for databases commonly known as Codd's rules. The rules mainly define what is required for a DBMS for it to be considered relational, i.e., an RDBMS. There is also one more rule i.e. Rule00 which specifies the relational model should use the relational way to manage the database. The rules and their description are as follows:- Rules: Rule 000: Zeroth rule: An RDBMS system should be capable of using its relational facilities (exclusively) to manage the database. Rule 1: The information rule: All information in the database is to be represented in one and only one way. This is achieved by values in column positions within rows of tables. Rule 2: The guaranteed access rule: All data must be accessible with no ambiguity. This is achieved in the RDBMS by using the primary key concept. Rule 3: Systematic treatment of null values: The DBMS must allow each field to remain null. The null can be stored in any field of any datatype. Rule 4: Active online catalog based on the relational model: The authorized users can access the database structure by using common language i.e. SQL. Rule 5: The comprehensive data sublanguage rule: The system must support at least one relational language that has simple syntax and transaction management facilities. It can be used in the application as well as in the RDBMS systems. ANKUR RAINA 09-IT-4505
  • 7. Rule 6: The view updating rule: All views must be updatable by the system. Rule 7: High-level insert, update, and delete: The system is able to insert, update and delete operations fully. It can also perform the operations on multiple rows simultaneously. Rule 8: Physical data independence: Changes to the physical storage structure must not require a change to an application based on the structure. Rule 9: Logical data independence: Changes to the logical level (tables, columns, rows, and so on) must not require a change to an application based on the structure. Rule 11: Distribution independence: The distribution of portions of the database to various locations should be invisible to users of the database. Rule 12: The non- subversion rule: If the system provides a low-level (record-at-a-time) interface, then that interface cannot be used to subvert the system, for example, bypassing a relational security or integrity constraint. Note:- Any database management system which fulfills 6 or more than 6 rules can be considered as the RDBMS. Rules satisfied by Oracle RDBMS Oracle RDBMS follows 11 out of 12 rules. One rule which is not followed is debatable. 1. View Updating Rule: It is because, according to Dr. E.F.Codd, every view should support full range of data manipulation, but in Oracle, it is not feasible for complex views based on multiple tables. ANKUR RAINA 09-IT-4505
  • 8. 2. Systematic Treatment of Null value Null in Oracle is treated as absence of a value or unknown status ( in case of comparison of values ) and it does not have any systematic representation. In Oracle, no two null values are equal (as this will return a value which is treated as unknown by Oracle). If there is a systematic representation, then NULL value must be comparable. ANKUR RAINA 09-IT-4505
  • 9. CHAPTER 3 Oracle Database Architecture The Oracle RDBMS consists of two main components:- 1. The Database or the Physical Structures 2. The Instance or the Memory Structures Control Files: These files contain data about the database itself, called the metadata. These files are critical to the database. Without them, one cannot open the data files to access the data within the database. Data Files: These files contain the data of the database. ANKUR RAINA 09-IT-4505
  • 10. Online Redo Log Files: These files allow for instance recovery of the database. If the database were to crash and not lose data files, the instance will be able to recover the database with the information in these files. Tablespaces and Data Files: ANKUR RAINA 09-IT-4505
  • 11. A database is divided into logical storage units called tablespaces, which can be used to group related logical structures. Each database is logically divided into one or more tablespaces. One or more data files are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace. Segments, Extents, and Blocks: Database objects such as tables and indexes are stored in tablespaces as segments. Each segment contains one or more extents. An extent consists of contiguous data blocks, which means that each extent can exist only in one data file. Data blocks are the smallest units of I/O in the database. When the database requests a set of data blocks from the operating system (OS), the OS maps this to the actual OS block on the storage device. Because of this, one needs not to be aware of the physical address of any data in the database. This also means that a data file can be striped and or mirrored on several disks. The size of the data block can be set at database creation time. The default size of 8K is adequate for more databases. If your database supports a data warehouse application that has large tables and indexes, then a larger block may be beneficial. If your database supports a transactional application where reads and writes are very random, then a smaller block size may be beneficial. The maximum block size is dependent on the OS. The minimum block size is 2K and should rarely (if ever) be used. There are other files that are not officially part of the database, but are important to the successful running of the database. These are: Parameter File: The parameter file is used to define how the instance will be configured when it starts up. ANKUR RAINA 09-IT-4505
  • 12. Password File: This file allows users to connect remotely to the database and perform administrative tasks. Archive Log Files: These files contain an ongoing history of the redo generated by the instance. These files allow for database recovery. By using these files and a backup of the database, it is possible to recover a lost file. Oracle Instance Management An Oracle Database server consists of an Oracle Database and an Oracle instance. An Oracle instance consists of memory buffers known as the System Global Area (SGA) and background processes. The instance is idle (non-existent) until it is started. When the instance is started, an initialization parameter file is read and the instance is configured accordingly. After the instance is started and the database is opened, users can access the database. ANKUR RAINA 09-IT-4505
  • 13. Oracle Memory Structures The basic memory structures associated with an Oracle instance include: System Global Area (SGA): It is shared by all server and background processes. Program Global Area (PGA): It is private to each server and background process; there is one PGA for each process. The SGA is a shared memory area that contains data and control information for the instance. The SGA consists of the following data structures: Database buffer cache: Caches blocks of data retrieved from the database. Redo log buffer: Caches redo information (used for instance recovery) until it can be written to the physical redo log files stored on disk. Shared pool: Caches various constructs that can be shared among users. Large pool: Is an optional area used for buffering large I/O requests. Java pool: Is used for all session-specific Java code and data within the Java Virtual Machine (JVM). ANKUR RAINA 09-IT-4505
  • 14. Stream pool: Is used by Oracle Streams. When we start the instance by using Enterprise Manager or SQL*Plus, the memory allocated for the SGA is displayed. A PGA is a memory region that contains data and control information for each server process. A server process services a client’s requests. Each server process has its own private PGA area that is created when the server process is started. Access to it is exclusive to that is created when the server process is started. Access to it is exclusive to that server process, and is read and written only by the oracle code acting on behalf of it. The amount of PGA memory used and its content depends on whether the instance is configured in shared mode. Generally, the PGA contains the following: Private SQL area: Contains data such as bind information and run-time memory structures. Each session that issues a SQL statement has a private SQL area. Session memory: Is memory allocated to hold session variables and other information related to the session. ANKUR RAINA 09-IT-4505
  • 15. CHAPTER 4 SQL Statements SQL stand for Structured Query Language. SQL has become the de-facto standard language used for creating and querying relational databases. The SQL statements can be categorized as:- Types of SQL Statements: Data Manipulation Language: It constitutes those commands which are used to maintain & query a database, including updating, inserting, modifying and querying data. SELECT INSERT UPDATE DELETE MERGE Data Definition Language: It constitutes those commands which are used to define a database including creating, altering and dropping tables and establishing constraints. CREATE ALTER DROP RENAME TRUNCATE COMMENT Data Control Language: It controls a database and deals with the administrative privileges. GRANT REVOKE ANKUR RAINA 09-IT-4505
  • 16. Transaction Control: A discrete unit of work that must be completely processed or not processed at all within a computer system is called a transaction. The following commands control the transactions. COMMIT ROLLBACK SAVEPOINT Capabilities of SQL SELECT statements: The three basic capabilities of SELECT statements are: Projection: To choose the columns in a table that is returned by a query. Selection: To choose the rows in a table that is returned by a query. Various criteria can be used to restrict the rows that are retrieved. Joining: To bring together data that is stored in different tables by specifying the link between them. Data Retrieval: Using SELECT Statement: SELECT identifies the columns to be displayed. FROM identifies the table containing those columns. If all columns are of data in a table are to be listed, an asterisk (*) can be used. ANKUR RAINA 09-IT-4505
  • 17. Defining a NULL value: A null is a value that is unavailable, unassigned, unknown, or inapplicable. A null is not the same as a zero. Columns of any data type can contain nulls. However, some constraints (NOT NULL and PRIMARY KEY) prevent nulls from being used in the column. ... Arithmetic expressions containing a null value evaluate to null. ... ANKUR RAINA 09-IT-4505
  • 18. Defining a Column Alias: A column alias is used to rename a column heading. It is useful with calculations. It either follows the column name or an optional AS keyword is used between the column name and alias. If the alias name is case sensitive, enclose it in double-quotation marks. Restricting Rows: Using WHERE clause: WHERE restricts the query to rows that meet a condition Condition is composed of column names, expressions, constants, and a comparison operator. Character Strings and Dates: Character strings and date values are enclosed in single quotation marks. Character strings are case sensitive, and date values are format sensitive. The default date format is DD-MON-RR. ANKUR RAINA 09-IT-4505
  • 21. Rules of Precedence Sorting Data: Sort retrieved rows with the ORDER BY clause: 1. ASC: ascending order, default 2. DESC: descending order The ORDER BY clause comes last in the SELECT statement. ANKUR RAINA 09-IT-4505
  • 22. Using Substitution Variables: Substitution variables are used to temporarily store values with a single-ampersand (&) and double-ampersand (&&) substitution. Substitution variables are used to supplement the following: 1. WHERE clause 2. ORDER BY clause 3. Column expressions 4. Table names 5. Entire SELECT statements Use the double ampersand (&&) if you want to reuse the variable value without prompting the user each time. ANKUR RAINA 09-IT-4505
  • 23. CHAPTER 5 Using Single Row Functions to Customize Output: Features: 1. Used to manipulate data items 2. Accept arguments and return one value 3. Act on each row that is returned 4. Return one result per row 5. May modify the data type 6. Can be nested 7. Accept arguments that can be a column or an expression General Functions: FUNCTION SYNTAX DESCRIPTION Converts a null value to actual NVL NVL(expr1,expr2) value. I f expr1 is not null, NVL2 NVL2 NVL2(expr1,expr2,expr3)returns expr2. If expr1 is null, NVL2 returns expr3. Compares two expressions NULLIF and returns null if they are NULLIF(expr1,expr2) equal; returns the first expression if they are not equal. Returns the first non-null COALESCE COALESCE(expr1,expr2,...,exprn) expression in the expression list. ANKUR RAINA 09-IT-4505
  • 24. USING NVL: USING NVL2: USING NULLIF: USING COALESCE: ANKUR RAINA 09-IT-4505
  • 25. CASE Expression: It facilitates conditional inquiries by doing the work of an IF-THEN_ELSE statement. ANKUR RAINA 09-IT-4505
  • 26. DECODE Function: It facilitates conditional inquiries by doing the work of a CASE expression or IF-THEN-ELSE statement. ANKUR RAINA 09-IT-4505
  • 27. CHAPTER 6 Reporting Aggregated Data Using Group Functions: Group Functions: Group functions operate on sets of rows to give one result per row. Types of Group functions are: FUNCTION SYNTAX DESCRIPTION AVG AVG([DISTINCT|ALL]n) Average value of n, ignoring null values. COUNT COUNT({*|[DISTINCT|ALL]expr}) No. of rows where expr evaluates to something other than null(count all selected rows using * , including duplicates and rows with nulls) MAX MAX([DISTINCT|ALL]expr) Max value of expr ignoring null values MIN MIN([DISTINCT|ALL]expr) Min value of expr ignoring null values STDDEV STDDEV([DISTINCT|ALL]x) Standard deviation of n ignoring null values SUM SUM([DISTINCT|ALL]n) Sum values of n ignoring null values VARIANCE VARIANCE([DISTINCT|ALL]x) Variance of n ignoring null values COUNT (*) returns the number of rows in a table. ANKUR RAINA 09-IT-4505
  • 28. COUNT (expr) returns the number of rows with non-null values for expr. COUNT (DISTINCT expr) returns the number of distinct non-null values of expr. Creating Groups of Data: GROUP BY Clause Syntax ANKUR RAINA 09-IT-4505
  • 29. Using GROUP BY clause on multiple columns Restricting Group Results with HAVING clause: When you use the HAVING clause, the Oracle Server restricts groups as follows: 1. Rows are grouped 2. The group function is applied 3. Groups matching the HAVING clause are displayed. ANKUR RAINA 09-IT-4505
  • 30. CHAPTER 7 Displaying Data Using Multiple Tables Creating Natural Joins: The NATURAL JOIN clause is based on all columns in the two tables that have the same name. It selects rows from the two tables that have equal values in all matched columns. If the columns having the same names have different data types, an error is returned. If several columns have the same names but the data types do not match, natural join can be applied by using the USING clause to specify the columns that should be used for an equijoin. Use the USING clause to match only one column when more than one column matches. Table name or alias is not used in the referenced columns. ANKUR RAINA 09-IT-4505
  • 31. Using Sub-Queries to Solve Queries: Sub-Query: A query within a query is known as a sub-query. A sub-query executes once before the main query. The result of sub-query is used by the main query. ANKUR RAINA 09-IT-4505
  • 32. CHAPTER 8 Manipulating Data: A Data Manipulation language (DML) statement is executed when you:  Add new rows to a table  Modify existing rows in a table  Remove existing rows from a table A transaction consists of a collection of DML statements that form a logical unit of work. INSERT Statement: Syntax: Implicit Method: omit the column from the column list. Explicit Method: Specify the NULL keyword in values clause. UPDATE Statement: UPDATE statement is used to modify the existing rows in a table. More than one row can be updated at a time (if required). ANKUR RAINA 09-IT-4505
  • 33. DELETE Statement: DELETE Statement is used to remove existing rows from a table. If one omits the WHERE clause, all the rows from the table will be deleted. TRUNCATE Statement: The TRUNCATE Statement removes all rows from a table, leaving the table empty and the table structure intact. It is a Data Definition Language (DDL) statement rather than a DML statement; cannot easily be undone. ANKUR RAINA 09-IT-4505
  • 34. ANKUR RAINA 09-IT-4505
  • 35. CHAPTER 9 Database Objects: CREATE Statement: ANKUR RAINA 09-IT-4505
  • 36. CREATE TABLE using a Sub-Query: Dropping a Table:  All data and structure in the table are deleted.  Any pending transactions are committed.  All indexes are dropped.  All constraints are dropped.  You cannot roll back the DROP TABLE statement. ANKUR RAINA 09-IT-4505
  • 37. Creating Other Schema Objects: Views:  To restrict data access.  To make complex queries easy.  To provide data independence.  To present different views of the same data. CREATE VIEW Syntax (simple view): CREATE VIEW (complex view): ANKUR RAINA 09-IT-4505
  • 38. You cannot modify data in a view if it contains:  Group functions  A GROUP BY clause  The DISTINCT keyword  The pseudo column ROWNUM keyword  Columns defined by expressions You cannot add data in a view if following conditions along with conditions above prevail:  NOT NULL columns in the base tables that are not selected by the view. Sequences: A sequence  Can automatically generate unique numbers  Is a sharable object  Can be used to create a primary key value  Replaces application code  Speeds up the efficiency of accessing sequence values when cached in memory Indexes: An index:  Is a schema object  Can be used by the Oracle server to speed up the retrieval of rows by using a pointer  Can reduce disk I/O by using a path access method to locate data quickly  Is independent of the table that it indexes  Is used and maintained automatically by the Oracle server ANKUR RAINA 09-IT-4505
  • 39. Indexes are created in the following two ways:  Automatically: A unique index is created automatically when you define a PRIMARY KEY or UNIQUE constraint in a table definition.  Manually: Users can create non-unique indexes on columns to speed up access to the rows. Syntax: Synonyms: Simplify access to objects by creating a synonym (another name for an object). With synonyms, we can:  Create an easier reference to a table that is owned by another user  Shorten lengthy object names ANKUR RAINA 09-IT-4505
  • 40. REFERENCES Web Resources  http://wiki.answers.com/Q/What_are_EF_ Codd_rules  www.oracle.com  www.wikipedia.com  www.oraclecoach.com Books:  Study material by Oracle University Press  Modern Database Management by Jeffrey A. Hoffer, Mary B. Prescott and Fred R. McFadden ANKUR RAINA 09-IT-4505