Oracle DB

29
Introduction to Oracle

Transcript of Oracle DB

Page 1: Oracle DB

Introduction to OracleIntroduction to Oracle

Page 2: Oracle DB

Oracle HistoryOracle History

• 1979 Oracle Release 2

• 1986 client/server relational database

• 1989 Oracle 6

• 1997 Oracle 8 (object relational)

• 1999 Oracle 8i (Java Virtual Machine)

• 2000 Oracle Application Server

• 2001 Oracle 9i database server

• 1979 Oracle Release 2

• 1986 client/server relational database

• 1989 Oracle 6

• 1997 Oracle 8 (object relational)

• 1999 Oracle 8i (Java Virtual Machine)

• 2000 Oracle Application Server

• 2001 Oracle 9i database server

Page 3: Oracle DB

Oracle FamilyOracle Family

• Personal Oracle- for single users. Used to develop systems

• Oracle Standard Edition- (Entry level Workgroup server)

• Oracle Enterprise edition- Extended functionality

• Oracle Lite- (Oracle mobile) single users using wireless devices.

• Personal Oracle- for single users. Used to develop systems

• Oracle Standard Edition- (Entry level Workgroup server)

• Oracle Enterprise edition- Extended functionality

• Oracle Lite- (Oracle mobile) single users using wireless devices.

Page 4: Oracle DB

Some Developer ToolsSome Developer Tools

• Oracle Forms Developer

• Oracle Reports Developer

• Oracle Jdeveloper

• Oracle Designer

• Oracle Forms Developer

• Oracle Reports Developer

• Oracle Jdeveloper

• Oracle Designer

Page 5: Oracle DB

File ProcessingFile Processing

Page 6: Oracle DB

DatabaseProcessing

Page 7: Oracle DB
Page 8: Oracle DB
Page 9: Oracle DB
Page 10: Oracle DB

Database StructureDatabase Structure

• Logical structure - maps the data to the Physical structure.

• Physical structure -part of the operating system’s file structure.

• Memory structure - where all the processing takes place.

• Logical structure - maps the data to the Physical structure.

• Physical structure -part of the operating system’s file structure.

• Memory structure - where all the processing takes place.

Page 11: Oracle DB

The Logical structuresThe Logical structures

• control how the data must be stored in the database.

• five Logical structures:– tablespaces – segments – extents – data blocks– schema objects

• control how the data must be stored in the database.

• five Logical structures:– tablespaces – segments – extents – data blocks– schema objects

Page 12: Oracle DB

Physical structuresPhysical structures

• Parameter files

• Password files

• Datafiles

• Redo log files

• Control files

• Parameter files

• Password files

• Datafiles

• Redo log files

• Control files

Page 13: Oracle DB

Memory structuresMemory structures

• System Global Area (SGA)

• Program Global Area (PGA)

• The Oracle database uses these memory areas to store information before they are made permanent in the database.

• System Global Area (SGA)

• Program Global Area (PGA)

• The Oracle database uses these memory areas to store information before they are made permanent in the database.

Page 14: Oracle DB

TableSpacesTableSpaces

• A database is divided into logical storage units called Tablespaces.

• logical construct for arranging different types of data

• An Oracle database must have at least a system tablespace.

• It is recommended to have different tablespaces for user and system data.

• A database is divided into logical storage units called Tablespaces.

• logical construct for arranging different types of data

• An Oracle database must have at least a system tablespace.

• It is recommended to have different tablespaces for user and system data.

Page 15: Oracle DB

TablespacesTablespaces

• a logical structure• a logical structure

Data1 Data2

Data1_01.dbf Data2_01.dbf Data2_02.dbf

The DATA1Tablespace =One datafile

The DATA2Tablespace =Two datafiles

Page 16: Oracle DB

Create TablespaceCreate Tablespace

CREATE TABLESPACE testDATAFILE '\oraserv\ORADATA\a.dbf'SIZE 10MAUTOEXTEND ON NEXT 10M MAXSIZE 100M;

CREATE TABLE cust(id int,name varchar2(20))TABLESPACE test;

CREATE TABLESPACE testDATAFILE '\oraserv\ORADATA\a.dbf'SIZE 10MAUTOEXTEND ON NEXT 10M MAXSIZE 100M;

CREATE TABLE cust(id int,name varchar2(20))TABLESPACE test;

Page 17: Oracle DB

7 Logical Tablespaces7 Logical Tablespaces

• SYSTEM

• DATA

• INDEX

• USERS

• ROLLBACK

• TEMP

• TOOLS

• SYSTEM

• DATA

• INDEX

• USERS

• ROLLBACK

• TEMP

• TOOLS

Page 18: Oracle DB

Schemas and Schema ObjectsSchemas and Schema Objects

• Collection of database objects– Tables– Views– Sequences– Synonyms– Indexes– Procedures– Functions– Packages– Triggers

• Collection of database objects– Tables– Views– Sequences– Synonyms– Indexes– Procedures– Functions– Packages– Triggers

Page 19: Oracle DB

Data BlocksData Blocks

• The smallest unit of Input/Output used by Oracle database.

• The size of data block for any database is fixed at the time of creation of the database;

• Some values of the data block size are 2KB, 8KB, 16KB, and 32KB.

• Oracle recommends a size of 8KB

• The smallest unit of Input/Output used by Oracle database.

• The size of data block for any database is fixed at the time of creation of the database;

• Some values of the data block size are 2KB, 8KB, 16KB, and 32KB.

• Oracle recommends a size of 8KB

Page 20: Oracle DB

ExtentsExtents

• The next level of data storage.• One extent consists of a specific number of

data blocks• One or more extents in turn make up a

segment.• When the existing space in a segment is

completely used, Oracle allocates a new extent for the segment.

• The next level of data storage.• One extent consists of a specific number of

data blocks• One or more extents in turn make up a

segment.• When the existing space in a segment is

completely used, Oracle allocates a new extent for the segment.

Page 21: Oracle DB

SegmentSegment

• A segment consists of a set of extents• Each table’s data is stored in its own single

segment.• Each index’s data is stored in a single segment. • More extents are automatically allocated by

Oracle to a segment if its existing extents become full.

• The different types of segments are the data segments, index segments,rollback segments, and temporary segments.

• A segment consists of a set of extents• Each table’s data is stored in its own single

segment.• Each index’s data is stored in a single segment. • More extents are automatically allocated by

Oracle to a segment if its existing extents become full.

• The different types of segments are the data segments, index segments,rollback segments, and temporary segments.

Page 22: Oracle DB

Physical Database StructurePhysical Database Structure

• Password file - which contain the password information for all users.

• Parameter file - which contains all the important information necessary to start a database.

• Datafiles - which contain the application data being stored, as well as any data necessary to store user-IDs, passwords, and privileges.

• Redo log files - which store all the transactions made to the database. These files are also called transaction log files.

• Control files - which store information specifying the structure of the database,such as the name and time of creation of the database and the name and location of the datafiles.

• Password file - which contain the password information for all users.

• Parameter file - which contains all the important information necessary to start a database.

• Datafiles - which contain the application data being stored, as well as any data necessary to store user-IDs, passwords, and privileges.

• Redo log files - which store all the transactions made to the database. These files are also called transaction log files.

• Control files - which store information specifying the structure of the database,such as the name and time of creation of the database and the name and location of the datafiles.

Page 23: Oracle DB

The Physical files that make up a database

Control files

Data filesRedo LogFiles

IdentifyIdentify

Record changes to

Page 24: Oracle DB

Control FilesControl Files

• Contain a list of all other files in the database

• Key information such as– Name of the database– Date created– Current state– Backups performed– Time period covered by redo files

• Contain a list of all other files in the database

• Key information such as– Name of the database– Date created– Current state– Backups performed– Time period covered by redo files

Page 25: Oracle DB

• Store a recording of changes made to the database as a result of transactions and internal Oracle Activities

• When Oracle fills one redo log, it automatically fills a second.

• Used for database recovery

• Store a recording of changes made to the database as a result of transactions and internal Oracle Activities

• When Oracle fills one redo log, it automatically fills a second.

• Used for database recovery

Redo Log FilesRedo Log Files

Page 26: Oracle DB

Security MechanismsSecurity Mechanisms

• Database users and schemas

• Privileges

• Roles

• Storage settings and quotas

• Resource limits

• Auditing

• Database users and schemas

• Privileges

• Roles

• Storage settings and quotas

• Resource limits

• Auditing

Page 27: Oracle DB

Data Access: SQLData Access: SQL

• Data definition language (DDL) statements

• Data manipulation language (DML) statements

• Transaction control statements

• Session control statements

• System control statements

• Embedded SQL statements

• Data definition language (DDL) statements

• Data manipulation language (DML) statements

• Transaction control statements

• Session control statements

• System control statements

• Embedded SQL statements

Page 28: Oracle DB

TransactionsTransactions

• A transaction is a logical unit of work that comprises one or more SQL statement executed by a single user. According to the ANSI/ISO SQL standard, with which Oracle is compatible, a transaction begins with the user’s first executable SQL statement. A transaction ends when it is explicitly committed or rolled back.

• A transaction is a logical unit of work that comprises one or more SQL statement executed by a single user. According to the ANSI/ISO SQL standard, with which Oracle is compatible, a transaction begins with the user’s first executable SQL statement. A transaction ends when it is explicitly committed or rolled back.

Page 29: Oracle DB

Transaction ExampleTransaction Example