Introduction to Oracle

Slides:



Advertisements
Similar presentations
The Architecture of Oracle
Advertisements

Introduction to Oracle
4 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Overview of Database Administrator (DBA) Tools
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 2 Overview of Database Administrator (DBA) Tools.
Oracle Architecture. Instances and Databases (1/2)
Page Footer Keed Education Oracle Database Administration Basic Copyright 2009 Keed Education BV Version Concept.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2007 all rights.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
Advanced Databases Basic Database Administration Guide to Oracle 10g 1.
A Guide to Oracle9i1 Introduction to Oracle9i Database Administration Chapter 11.
Backup and Recovery Part 1.
Introduction History The principles of the relational model were first outlined by Dr. E.F Codd in a June 1970 paper is called “A Relational Model of Data.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Oracle Architecture. Database instance When a database is started the current state of the database is given by the data files, a set of background (BG)
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
1 Copyright © 2009, Oracle. All rights reserved. Exploring the Oracle Database Architecture.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle on Windows Server Introduction to Oracle10g on Microsoft Windows Server.
Basic Oracle Architecture
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
CSE 781 – DATABASE MANAGEMENT SYSTEMS Introduction To Oracle 10g Rajika Tandon.
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
The protection of the DB against intentional or unintentional threats using computer-based or non- computer-based controls. Database Security – Part 2.
7202ICT – Database Administration
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
An Oracle server:  Is a database management system that provides an open, comprehensive, integrated approach to information management.  Consists.
IT Database Administration SECTION 01. Starting Up and Shutting Down the Database Database Administration Facilities – A number of tools are available.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Introduction to Oracle. Oracle History 1979 Oracle Release client/server relational database 1989 Oracle Oracle 8 (object relational) 1999.
IT Database Administration Section 09. Backup and Recovery Backup: The available options Full Consistent (cold) Backup Database shutdown, all files.
Process Architecture Process Architecture - A portion of a program that can run independently of and concurrently with other portions of the program. Some.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown President System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2003.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
18 Copyright © 2004, Oracle. All rights reserved. Backup and Recovery Concepts.
Oracle Architecture - Structure. Oracle Architecture - Structure The Oracle Server architecture 1. Structures are well-defined objects that store the.
3 Copyright © 2004, Oracle. All rights reserved. Creating an Oracle Database.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
7 Copyright © Oracle Corporation, All rights reserved. Instance and Media Recovery Structures.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
What is Oracle ? Oracle is a relational database management system. It is a management system which uses the relational data model. In the relational data.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
Oracle Database Architectural Components
1 Copyright © 2005, Oracle. All rights reserved. Oracle Database Administration: Overview.
Backup and Recovery.
Table spaces.
Database structure and space Management
Database System Concepts and Architecture
Chapter 6 - Database Implementation and Use
SQL and SQL*Plus Interaction
Oracle Architectural Components
ORACLE SQL Developer & SQLPLUS Statements
Chapter 8 Working with Databases and MySQL
Introduction To Oracle 10g
Oracle Memory Internals
Oracle Architectural Components
Using SQL*Plus.
Chapter 11 Managing Databases with SQL Server 2000
Database administration
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

Introduction to Oracle Oracle Architecture, SQL* Plus,

Oracle A database as a collection of related information A database management system (DBMS) is a software suite designed to store and manage databases: Provides environment that is both convenient and efficient to use Oracle is a relational database management system (RDBMS)

Oracle Architecture Files: Programs: Memory area: Database files. At least one file per tablespace. Log files. Usually a group of files; the db writes to one file at a time. Control file. Contains information about the database files. Usually 3 copies, for safety. Configuration files: initX.ora Programs: Background process. Pool of processes (/threads) handling incoming requests. Memory area: SGA: Shared Global Area. Contains database buffers, rollback buffers, cursors. External Database Structures Back Up / Recovery Security Basic Database Implementation

Database and Instance Database: Since the physical structures of Oracle are maintained on a computer, they must be stored in files. Logically, the files belong to tablespaces. When a file is used to store data from an Oracle tablespace, it is called a datafile. A datafile belongs to exactly one tablespace, but a tablespace may consist of (/be stored in) several datafiles. Datafiles can be resized, placed in aspecific directory: tuning(DBA)

Database and Instance Instance: A database instance (also known as a server) is a set of memory structures and background processes that access a set of database files One database may be accessed by more than one instance, Note also that when a database has been shut down (assuming a single-instance database), the instance does not exist. The instance is shared by a set of users: No user accesses the database directly; all access goes through the instance. (security, efficiency)

Internal database structures In this context, we define anything stored in datafiles as internal database structures. This includes tables, columns, constraints, data types, users, schemas, indexes, clusters, hash clusters, views, sequences, procedures, functions, packages, triggers, synonyms, privileges, roles, database links, temporary segments and rollback segments.

Internal database structures Tables, columns, constraints and data types: A table, the primary storage structure of an Oracle database, consists of a set of columns. The table has a name, and each column has a name. Tables are related through column contents; the relationships are enforced with referential integrity constraints Tables owned by user SYS constitute the data dictionary (DD) Column characteristics consist of data type and length.

Internal database structures Abstract data types / objects: The SQL command CREATE TYPE ... AS OBJECT is used to create abstract data types in Oracle The data type will behave like an object: Oracle will create a constructor method for it; the constructor is called when an object is inserted in a column with that data type.

Internal database structures Partitions: Tables and indexes may be split into partitions. Each partition can be stored in a particular tablespace, and thereby be directed to a particular disk (through datafile placement). Partitioning is used to ease maintenance and improve performance.

Internal database structures Users and schemas: Objects like tables, indexes, clusters and views are created under particular user accounts. The SYS user owns the data dictionary; the SYSTEM user owns the views used to access the DD. A set of objects that belong to a user account are called a schema, so in many cases oracle use the words user and schema interchangeably.

Internal database structures Indexes: In relational database theory, the ordering of rows in a RDB is irrelevant. When we want to access a particular row, we therefore either have to search through the table from the beginning until we find the row we are looking for, or use an indirect search via an index. Each index entry will consist of values for the indexed columns and the RowID for the row where the values appear. A RowID consists of fileID, block number within the file, and row number within the block. An index is created in a tablespace.

Internal database structures Clusters and hash-clusters: If rows from different tables are accessed together most of the time, we may store them in a cluster instead of in the regular separate tables, in order to speed up access. The related columns in the tables belonging to the cluster will be indexes using a cluster index. We may also use a hash cluster. In this case, we use a hash function (instead of a cluster index) to determine the location of a particular row-set in the cluster.

Internal database structures Views, Sequences: A view is, conceptually, a mask placed on top of one of more tables Sequences are used to simplify programming efforts by providing a sequential list of unique numbers.

Internal database structures Procedures, functions and packages: A procedure is a block of PL/SQL statements that is stored in the data dictionary and is called by applications... When the procedure is executed, its statements are executed as a unit The only difference between a function and a procedure is that a function returns a value Packages are used to arrange procedures and functions into logical groupings.

Internal database structures Triggers: Triggers are procedures that are executed when a specified database event takes place against a specified table. You may use them to augment referential integrity, enforce additional security, or enhance the available auditing options.

Internal database structures Synonyms: In order to identify a particular row in an Oracle table, we have to specify the database and the schema to which the table belongs, the table name, and the primary key of the row. The database may be identified by the machine name and the instance name We sometimes want to hide some of these layers of identification to the users, whether they be applications or ad hoc users. This can be done using synonyms.

Internal database structures Privileges and roles: In order to access an object owned by another account, the privilege to access that object must first have been granted Typical access privileges: Table: Select, insert, update, delete. Procedure, function, package: Execute. Snapshot: Select. it may become quite cumbersome to maintain privileges when the number of user accounts and objects increases. The solution is to introduce roles, privilege groups: privilege can be granted to a user or a role, and a role can be granted to a role or a user.

Internal database structures Database links: If an Oracle database is linked to another Oracle database through a network, a user may access objects in the remote database as easily as in the local one This is done through database links By combining database links and synonyms, we may create an environment where the (application or ad hoc) user may mix and match data from local and remote tables without being aware of the physical location of data

Segments, extents and blocks These concepts are used to organise many, but not all, of the internal structures. Segments are the physical counterparts to logical database objects. Segments store data... Because a segment is a physical entity, it must be assigned to a tablespace in the database (and will thus be placed in one of the datafiles of that tablespace) A segment is made up of sections called extents – contiguous sets of Oracle blocks. Once the existing extents in a segment can no longer hold new data, the segment will obtain another extent (until no more free space or internal maximum number of extents per segment ) The size of each block within an extent is determined at database creation time.

Special purpose segments Rollback segments: used to contain a copy of rows as they appeared before being changed by a transaction(to give other users a consistent view of the database. ) Temporary segments: These are used to perform sorting. They may be needed during execution of SELECT statements and creation of indexes.

Internal memory structures Most common ones: System Global Area (SGA), consisting of Data block buffer cache Dictionary cache Redo log buffer Shared SQL pool Context areas Program Global Area (PGA)

Internal memory structures System Global Area: This area acts as the common ground for all the database users; any information that more than one user may need is kept here for efficiency.

Internal memory structures SGA components: Data block buffer cache: Data is read from segments (like tables and indexes) into this cache. Dictionary cache: Information about database objects is stored in the data dictionary tables. This information includes user account data, datafile names, segment names, extent locations, table descriptions, and privileges. When this information is needed by the database, the data dictionary tables are read and the data that is returned is stored in the SGA in the dictionary cache.

Internal memory structures SGA components: Redo log buffer: Redo entries describe the changes that are made to the database. They are written to the online redo log files so that they can be used in roll-forward operations during database recoveries The information being written to the redo log files is first recorded in the redo log buffers in the SGA Shared SQL pool: This contains The dictionary cache The other part is the library cache, which contains “the execution plan and parse tree for SQL statements run against the database

Internal memory structures Context areas: used for private object caches when the object-relational features are used. Program Global Area: Each user process currently connected has its own PGA. each PGA is private for the user.

Background processes outlines the interaction between the physical structures, memory structures and processes that constitute an Oracle database When the instance starts, it initiates a range of background processes. Depending on the configuration and options of the installation, different processes may start, but the core set will always be there.

Background processes SMON: The System Monitor is responsible for performing instance recovery on startup This is necessary if the database was shut down using the ABORT option or if it was improperly shut down (for instance due to power failure). PMON: The Process Monitor, as the name implies, monitors user processes and cleans up after failed processes free the resources that the processes were using.

Background processes DBWR: The database writer process is responsible for reading and writing the database files. LGWR: The log writer process reads redo log buffers and writes to the redo log files. redo log buffers are always flushed to disk when a transaction is committed.

Background processes CKPT: A Checkpoint is an instruction to the RDBMS to write all updated database blocks to disk and record the checkpoint timestamp in datafile headers and control files ARCH: The Archiver background process is responsible for copying each redo log file to an archive medium once it has been filled RECO: The Recoverer background process is only used in distributed databases RECO attempts to access databases involved in in-doubt distributed transactions and resolve the transactions SNPn: The optional set of Snapshot background process are responsible for refreshing snapshots and schedule jobs

Background processes LCKn: When the Parallel Server option is being used, the RDBMS needs lock processes to ensure that the different instances accessing the single database do not create inconsistencies by interfering with each other. Dnnn: When the MultiThreaded Server (MTS) option is used, each Dispatcher process will handle several connections for a protocol. Snnn: These processes handle connections that require a dedicated server, and are capable of performing I/O against datafiles just like the DBWR process/es.

External database structures In this section we concentrate on files that are part of the database architecture but do not store user data. Redo logs: We already know that the LGWR background process produces redo log files the files contain every transaction performed against the database The log files are used to recover the database after a SHUTDOWN ABORT or a crash Control files: Control files record control information about all of the files within the database. They are used to maintain internal consistency and guide recovery operation. Diagnostics files: The files that contain diagnostic information about the database consist of the alert log and trace files. The alert log records the commands and command results of major events in the life of the database (vital source of information for day-to-day management of a database ) Each of the background processes running in an instance has a trace file associated with it. The trace file will contain information about significant events encountered by the background process (most useful when attempting to discover the cause of a major failure. )

Backup/ recovery Export/ import: The Export utility queries the database and stores its output in a binary file. We can export a table or set of tables, a user or set of users, or the complete database. The only program that can interpret the binary format of the export file is the Import utility. This program can be used to import a table or set of tables, a user or set of users, or the complete database.

Backup/ recovery Offline backup: We can make a physical backup of the database by shutting it down and making a physical copy of all necessary files. The disadvantage of this backup method is obviously that the database is unavailable for the users during the backup. Online backup: If offline backup is unacceptable, we can run the database in ARCHIVELOG mode and perform online backup.

Security Account security: Oracle users can be allowed access on the basis of their operating system user account or on the basis of an Oracle-controlled password System-level privileges: We can generate our own roles containing system level privileges Object security: The owner of an object can assign access privileges for the object to other users or roles Auditing: Auditing means monitoring the actions of users in the database. we can audit login attempts, table accesses and DBA-privileged activities The results are written to an audit table in the database (or to the operating system, if the OS is capable of it)

Basic database implementation The basic Oracle database will contain a datafile, a control file and two redo log files. Internally, it will contain at least two schemas (SYS and SYSTEM), at least one rollback segment (SYSTEM), at least one tablespace (SYSTEM), and the set of data dictionary tables. The instance will contain an SGA, the SMON, PMON, DBWR and LGWR background processes, and one user process including PGA per user.

Basic database implementation a database with this setup will be useless for most practical purposes – even for demonstrations In order to use the database for something, we need to ensure that it doesn't crash from a full SYSTEM tablespace That developers are able to create tables and other objects that a proper backup and recovery plan is implemented etc.

INTRODUCTION TO SQL*PLUS SQL* PLUS: What is it and what is it for? SQL*PLUS: First glance SQL*PLUS: Features SQL*PLUS: To Run SQL Commands SQL*PLUS: Interactive Model SQL*PLUS: Batch Mode I N D E X  SQL*PLUS: Oracle Control Tables SQL*PLUS: Miscellaneous

SQL* PLUS: What is it and what is it for? Command line SQL and PL\SQL language interface to the database  It can be used as an interactive interface or it can be driven from scripts. Its equivalents in other databases are as: Ingres: SQL Sybase and SQLServer: isql IBM DB2:db2 PostgresQL: psql MySQL:mysql What is it for? Connect to Oracle Create, change, delete database objects and data Ad hoc query data objects and data Verify the functioning of your applications

SQL*PLUS: First glance Start Up: In Windows Environment: Go to start—All Programs– Oracle– Applications Development—sql Plus Then SQL* Plus asks for your username and password You are now entering the application tool and ready to execute any ad hoc SQL command.

SQL*PLUS: First glance Changing your password: You can use SQL* Plus to change your password in Oracle by At the SQL* Plus prompt (SQL prompt is SQL>) type: SQL>  ALTER USER [userid] IDENTIFIED BY [newpasswd]; User altered. Please note that the [userid] here does NOT have @ora10g and the password is case-insensitive and is NOT cover by quote (').

SQL*PLUS: First glance Exit: To exit, at the SQL* Plus prompt type: SQL>  exit Disconnected from Oracle10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Oracle  Data Mining  options 

SQL*PLUS: Features Use with any SQL commands: create, drop, insert, select, update, delete and etc. Commands are case-insensitive except string constants/literals. Example: select name, class, major from Student where name = 'John'; is equivalent to: SELECT Name, CLaSs, MaJor From student where NaMe = 'John'; but not: select name, class, major from Student where name = 'JOHN';

SQL*PLUS: To Run SQL Commands Two ways to run sql commands: Interactive mode: type commands directly at the SQL prompt. Batch: create a set of commands in a file and run it in SQL*PLUS.

SQL*PLUS: Interactive Model At the SQL*PLUS prompt, you can type in any SQL query. The query will be sent to the Oracle server for executing and the results will be given back to your terminal interactively. For instance to create a table 'STUDENT', type at prompt: SQL> CREATE TABLE Student 2 ( Name VARCHAR2(30), 3 StudentNumber NUMBER(4) NOT NULL, 4 Class NUMBER(4), 5 Major VARCHAR2(4), 6 Primary key (StudentNumber) 7 ); Table created. SQL-Command Note: It is suggested that we use VARCHAR2 instead of VARCHAR

SQL*PLUS: Batch Mode Use your favorite editor to create a file with extension '.sql' containing your SQL command(s). From the batch file, you can run it by typing at prompt: @[filename] or start [filename] Note that the file extension '.sql' can be omitted.

I N D E X SQL*PLUS Commands @ Connect Describe Disconnect Edit Exit or Quit List Prompt Remark Set Save Spool Start   SQL Commands Data Definition Commands - Alter Table - Create Table - Create View - Drop Table - Drop View Data Manipulation Commands - Delete - Insert - Select - Update Transaction Control - Commit - Rollback

SQL*PLUS: Oracle Control Tables Internally, Oracle keeps its data catalog in the form of tables. There are quite a number of these tables. The followings are some that might be useful for you. Some Useful Control Tables: User_Catalog: user table catalog (e.g., table name, type --table, view) User_Tables: table detail (e.g., Identification, Space, Statistics-related) User_Views: views detail User_TS_Quotas: space allocation User_Users: your account information User_Sys_Privs: your privilege You can use 'describe' to show the structures of these tables and use 'select' to view their contents.

SQL*PLUS: Miscellaneous This is the closing page for the SQL*PLUS. Some useful miscellaneous items are listed here: Save your last SQL stmt. SQL> SAVE [filename] Spool the screen to a file SQL> SPOOL [filename] the SQL*PLUS will start recording your displayed output into your specific [filename] with the default file extension '.lst'. To stop spooling and save the file: SQL> SPOOL OFF For more information on SQL *PLUS, view SQL* Plus HELP (SQL> help [topic])

For More Information on Oracle Visit the Oracle Technology Center: http://www.oracle.com/technology/tech/index.html For Free video Tutorial on Oracle Database: http://www.vtc.com/products/oracle.htm