Download Creating Databases

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Entity–attribute–value model wikipedia , lookup

DBase wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Commitment ordering wikipedia , lookup

Microsoft Access wikipedia , lookup

Encyclopedia of World Problems and Human Potential wikipedia , lookup

Serializability wikipedia , lookup

Global serializability wikipedia , lookup

IMDb wikipedia , lookup

PL/SQL wikipedia , lookup

Btrieve wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Functional Database Model wikipedia , lookup

Oracle Database wikipedia , lookup

Ingres (database) wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Database wikipedia , lookup

Relational model wikipedia , lookup

Healthcare Cost and Utilization Project wikipedia , lookup

Versant Object Database wikipedia , lookup

Concurrency control wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

ContactPoint wikipedia , lookup

Transcript
IT 21003
Database Administration
SECTION 02
CREATING DATABASES
Creating a Database: Overview
1. Plan the physical design and storage
structures
2. Back Up any existing databases
3. Set the instance indentifier
4. Connect to Enterprise Manager or other
utility and startup an instance
CREATING DATABASES
Creating a Database: Overview
5. Create the database using an appropriate
facility
6. Run any required post-installation scripts
7. Back Up the new database
CREATING DATABASES
Pre-Creation Activities: Planning
– Plan the Tables and Indexes
• Estimate Sizes
– Plan the Backup and Recovery strategy
CREATING DATABASES
Pre-Creation Activities: Planning
– Creating a Database can overwrite existing
database files
• In practice a new init.ora file is often
created by copying and editing an
existing one
• If the Control_Files parameter is not
changed, existing files may be
overwritten
CREATING DATABASES
Pre-Creation Activities: Planning
• The Instance_Name and Database_Name
also need changed
• Decide on New Database or Migration
of old Database
CREATING DATABASES
Pre-Creation Activities: Parameter Files
– Create and edit the required parameter file(s)
• The parameter file configures the instance
that will be used to create the database
– Rename and edit a supplied init.ora file or
utilize an existing file
• Make sure the name is changed, do not
use the same parameter file for different
databases
• initprod.ora for production instance
• initest.ora for test instance
CREATING DATABASES
Pre-Creation Activities: Parameter Files Cont’d
– Examine the following parameters in your
file
• (DB_NAME)
• (DB_BLOCK_SIZE)
• (PROCESSES)
• (LICENSE_SESSION_WARNING)
CREATING DATABASES
Pre-Creation Activities: Parameter Files Cont’d
– Examine the following parameters in your
file
• (CONTROL_FILES)
• (DB_BLOCK_BUFFERS)
• (LICENSE_MAX_SESSIONS)
• (LICENSE_MAX_USERS)
– These MUST BE CHANGED
CREATING DATABASES
DB_NAME
– String of eight or fewer characters used to
identify the local name component of the
database name
• To avoid confusion, this should match
the Oracle instance identifier
– DB_NAME is stored in the datafile
headers, redo log files, and control files
– This parameter is not easy to change once
the database has been created
CREATING DATABASES
CONTROL_FILES
– Control_Files can be specified within the
parameter file as follows:
• CONTROL_FILES=/usr/oracle/home/con
trol_file,
/usr/oracle/home/control_file2
CREATING DATABASES
CONTROL_FILES
– At least TWO FILES should be specified so
that the loss of a control file is not critical
– The control files should be placed on
DIFFERENT DISKS
CREATING DATABASES
CONTROL_FILES
– If a name for the control file is not specified,
an operating-system-dependent default file
is created
– Be careful on Create Database the control
files are replaced, could cause old databases
to not function
CREATING DATABASES
DB_BLOCK_SIZE
– DB_BLOCK_SIZE specifies the size of a
database block and therefore the size of the
database buffers in SGA
CREATING DATABASES
DB_BLOCK_SIZE
– Default size is operating-system dependent
• Usually set at either 2Kb or 4Kb or 2048
kb or 4096 kb
• More realistic size is 16Kb or 32Kb
• It should be an exact multiple of the OS
block size
CREATING DATABASES
DB_BLOCK_SIZE
– The parameter should probably be
increased, if:
• The Oracle host machine is very large,
has lots of memory, and lots of fast
storage
• If there are a relatively high number of
large rows
• Not many requests for small amounts of
data
CREATING DATABASES
DB_BLOCK_SIZE
– Oracle to 8i – block size cannot be changed
once set without restructuring the database
– Oracle 9i up – block size can be changed
CREATING DATABASES
DB_BLOCK_BUFFERS
– DB_BLOCK_BUFFERS is the total
number of buffers(database blocks) in the
buffer cache at one time
CREATING DATABASES
DB_BLOCK_BUFFERS
– Governs the size of the large portion of the
SGA and can have profound effect on
performance
– Size of each buffer is determined by
DB_BLOCK_SIZE
CREATING DATABASES
DB_BLOCK_BUFFERS
– Estimate the number of buffers by
determining the number of blocks each
application accesses at one time (include
data, index, and rollback segment blocks)
– High values enable larger cache, which
may reduce I/O
• If set too high, the SGA may be larger
than physical memory and lead to
swapping, and reduction in system
performance
CREATING DATABASES
The PROCESSES Parameter
– Determines the maximum number of users
who can connect to the instance at any one
time
CREATING DATABASES
The PROCESSES Parameter
– To estimate the number required:
• One for each Server Process
• Overhead of One Process required for
each Background Process
CREATING DATABASES
The PROCESSES Parameter
– Example:
• If the required maximum number of users
connected to an instance at one time is
100, the setting of PROCESSES may
need to be 107
• PROCESSES = Background + Users
CREATING DATABASES
Listing Additional Parameters
– To obtain a list of parameters and their
current values for an instance
• Connect as a DBA
• SELECT *
• FROM v$parameter;
CREATING DATABASES
Setting the Instance Identifier (SID)
– The instance identifier is used by the
operating system to determine the default
instanced for database connections
– The value is often the DB_NAME of the
database
– Setting the instance identifier is operatingsystem specific
– Utilize SQL Plus Worksheet or Oracle
Enterprise Manager
CREATING DATABASES
Creating the Database
– Syntax:
– CREATE DATABASE [database_name]
– [CONTROLFILE REUSE]
– [LOGFILE {GROUP integer} filespec]
– [MAXLOGFILES integer]
CREATING DATABASES
Creating the Database
– Syntax Cont’d:
– [DATAFILE filespec, filespec]
– [MAXDATAFILES integer]
– [MAXINSTANCES integer]
– [ARCHIVELOG | NOARCHIVELOG]
– [CHARACTER SET charset];
– [NATIONAL CHARACTER SET charset];
CREATING DATABASES
Creating the Database Example:
CREATE DATABASE db1
DATAFILE ‘E:\production\system_dbf’ SIZE 50M
LOGFILE GROUP 1
(‘E:\production\log01\dev_log1a.rdo’,
‘E:\production\log01\dev_log1b.rdo’,
‘E:\production\log01\dev_log1c.rdo’) SIZE 1M
GROUP 2 (‘E:\production\log02\dev_log2a.rdo’,
‘E:\production\log01\dev_log2b.rdo’,
‘E:\production\log01\dev_log2c.rdo’) SIZE 1M;
CREATING DATABASES
Creating the Database Example Results:
• Creates a database named db1
• Creates two online redo log groups with three
log files of 1mb each
• Creates a SYSTEM tablespace with size of
50MB
• Remember that other parameters will be
loading default values
• Example: MAXDATAFILES will be set to 32
CREATING DATABASES
Database Creation Parameters
– database_name
• Name of the database being created
• Character string of up to eight characters
• Defaults to DB_NAME in the parameter
file used at startup time
– Specify this parameter to ensure that
the correct parameter file is used
CREATING DATABASES
Database Creation Parameters
– CONTROLFILE REUSE – (NEVER USE
THIS)
• Specifies that the control files listed in
the parameter file are to be overwritten
(if they already exist)
CREATING DATABASES
Database Creation Parameters
– LOGFILE
• Specifies one or more redo log files
• Each filespec specifies one or more redo
log groups, each of which contain more
than one file
• If the GROUP clause is omitted, a
default group is created
• If omitted, two redo log file groups are
created by default
CREATING DATABASES
Database Creation Parameters Cont’d
– DATAFILE
• One or more files to be used for the
SYSTEM tablespace
• If omitted, Oracle creates an
operating-system-dependent file in the
default directory
• Files can be specified to extend
automatically
CREATING DATABASES
Database Creation Parameters Cont’d
– ARCHIVELOG | NOARCHIVELOG
• Specifies whether the database will be
in ARCHIVELOG more or
NOARCHIVELOG mode
CREATING DATABASES
Database Creation Parameters Cont’d
– CHARACTER SET
• Specifies the character set that will be
use for the database
– NATIONAL CHARACTER SET
• Specifies the national character set to
be used for the database
– Defaults to CHARACTER SET
CREATING DATABASES
Database Creation Parameters Cont’d - Limits
– The MAX...parameters limit the size of the
control file
• The control file has to reserve space for
the file details
– MAXLOGFILES
• Integer value specifying the maximum
number of redo log file groups that the
database will have
CREATING DATABASES
Database Creation Parameters Cont’d - Limits
– MAXLOGMEMBERS
• Maximum number of log members
(files) in a group
CREATING DATABASES
Database Creation Parameters Cont’d - Limits
– MAXDATAFILES
• Integer value specifying the maximum
number of datafiles that can make up the
database
– Default value is 32, difficult to change
after database creation depending on
the Oracle version used
• DB_FILES in the parameter can be used
to temporarily reduce the parameter
CREATING DATABASES
CREATE DATABASE Operations
– CREATE DATABASE automatically does
the following:
• Creates (or overwrites) the Control Files
• Creates the Database Files
• Creates the Redo Log Files
• Creates the SYSTEM rollback segment
in the SYSTEM tablespace
CREATING DATABASES
CREATE DATABASE Operations
• Creates and loads the Data Dictionary
Tables
– A script called sql.bsq is run to create
the tables
– Change this file parameters before
running CREATE DATABASE
• Mounts the Database
• Opens the Database
• Creates the SYS and SYSTEM Users
CREATING DATABASES
Post Creation Activities
– The CREATE DATABASE statement
builds the dictionary base tables
• These tables are extremely difficult to
read
• Their structure may change across
releases of Oracle
CREATING DATABASES
Post Creation Activities
– Scripts need to be run to create views on
the base tables
• Held in the
ORACLE_HOME\rdbms\admin folder
– catalog.sql
• Builds some basic views on the
dictionary tables
– catproc.sql
• Builds the views for procedural objects
(packages, procedures, etc)
CREATING DATABASES
Post Creation Activities Cont’d
– Change passwords for SYS and SYSTEM users
• Initially, password for SYS is set to
change_on_install and SYSTEM password is
manager
– Create additional tablespaces, rollback
segments, control files, and redo log files and
backup the entire database
– Create the user accounts
– Create and populate the tables and other storage
structures