33
Creating an Oracle Database

Creating an Oracle Database

  • Upload
    ivie

  • View
    37

  • Download
    0

Embed Size (px)

DESCRIPTION

Creating an Oracle Database. Considerations before creating a DB. Planning for Database Creation Select the standard database block size. Use an undo tablespace to manage your undo records Develop a backup and recovery strategy to protect the database from failure - PowerPoint PPT Presentation

Citation preview

Page 1: Creating an  Oracle Database

Creating an Oracle Database

Page 2: Creating an  Oracle Database

Considerations before creating a DB

Planning for Database Creation– Select the standard database block size.– Use an undo tablespace to manage your undo

records– Develop a backup and recovery strategy to

protect the database from failure– Familiarize yourself with the principles and

options of starting up and shutting down an instance and mounting and opening a database.

Page 3: Creating an  Oracle Database

Considerations before creating a DB

Deciding How to Create an Oracle Database• Creating information structures, including the

data dictionary, that Oracle requires to access and use the database

• Creating and initializing the control files and redo log files for the database

• Creating new datafiles or erasing data that existed in previous datafiles

• Use the Database Configuration Assistant (DBCA).

• Create the database manually from a script.

Page 4: Creating an  Oracle Database

Planning Database File Locations• Keep at least two active copies of a

database control file on at least two different devices.

• Multiplex the redo log files and put group members on different disks.

• Separate data files whose data:– Will participate in disk resource contention

across different physical disk resources– Have different life spans– Have different administrative characteristics

Page 5: Creating an  Oracle Database

Creating a Database Using DBCA

• Selecting the Template

• Including Datafiles

• Specifying Global Database Name and Database Features

• Specifying Database Features

• Specifying Mode, Initialization Parameters, and Datafiles

Page 6: Creating an  Oracle Database

Manually creating an Oracle DB• Step 1: Decide on Your Instance Identifier (SID)• Step 2: Establish the Database Administrator Authentication

Method• Step 3: Create the Initialization Parameter File• Step 4: Connect to the Instance• Step 5: Start the Instance.• Step 6: Issue the CREATE DATABASE Statement• Step 7: Create Additional Tablespaces• Step 8: Run Scripts to Build Data Dictionary Views• Step 9: Run Scripts to Install Additional Options (Optional)• Step 10: Create a Server Parameter File (Recommended)• Step 11: Back Up the Database.

Page 7: Creating an  Oracle Database
Page 8: Creating an  Oracle Database

Create Database

• CREATE DATABASE [ database ] { USER SYS IDENTIFIED BY password | USER SYSTEM IDENTIFIED BY password | CONTROLFILE REUSE | MAXDATAFILES integer | MAXINSTANCES integer | CHARACTER SET charset | NATIONAL CHARACTER SET charset | SET DEFAULT { BIGFILE | SMALLFILE } TABLESPACE | database_logging_clauses | tablespace_clauses | set_time_zone_clause }... ;

Page 9: Creating an  Oracle Database

Database Logging Clauses

Page 10: Creating an  Oracle Database

• { LOGFILE [ GROUP integer ] file_specification [, [ GROUP integer ] file_specification ]... | MAXLOGFILES integer | MAXLOGMEMBERS integer | MAXLOGHISTORY integer | { ARCHIVELOG | NOARCHIVELOG } | FORCE LOGGING }

Page 11: Creating an  Oracle Database

Tablespace Clauses

Page 12: Creating an  Oracle Database

• { EXTENT MANAGEMENT LOCAL | DATAFILE file_specification [, file_specification ]... | SYSAUX DATAFILE file_specification [, file_specification ]... | default_tablespace | default_temp_tablespace | undo_tablespace }

Tablespace Clauses

Page 13: Creating an  Oracle Database

Default Tablespace

Page 14: Creating an  Oracle Database

• DEFAULT TABLESPACE tablespace [ DATAFILE datafile_tempfile_spec ] extent_management_clause

Page 15: Creating an  Oracle Database

Extent Managment Clause

Page 16: Creating an  Oracle Database

• EXTENT MANAGEMENT { DICTIONARY | LOCAL [ AUTOALLOCATE | UNIFORM [ SIZE size_clause ] ] }

Page 17: Creating an  Oracle Database
Page 18: Creating an  Oracle Database

Database creations are of three types:

• Copy an existing database and delete the old database.

• Copy an existing database and keep the old database.

• Create a new database when no database exists on your system.

Page 19: Creating an  Oracle Database
Page 20: Creating an  Oracle Database

Considerations before creating a DB

Planning for Database Creation– Plan the database tables and indexes and

estimate the amount of space they will require.– Plan the layout of the underlying operating

system files that are to comprise your database.– Select the global database name, DB_NAME,

DB_DOMAIN– Familiarize yourself with the initialization

parameters– Select the database character set.– Consider what time zones your database must

support.

Page 21: Creating an  Oracle Database

Creating Directories

Page 22: Creating an  Oracle Database

Exporting an Existing Database

C:\> exp SYSTEM/password

FILE=myexp.dmp

FULL=y LOG=myexp.log

C:\> set ORACLE_SID=orcl

C:\> exp SYSTEM/password FILE=myexp.dmp FULL=y LOG=myexp.log

Page 23: Creating an  Oracle Database

Deleting Database Files

1. Shut down starter database orcl at the command prompt:

C:\> oradim -SHUTDOWN -SID orcl -USRPWD password -SHUTTYPE inst -SHUTMODE i

Page 24: Creating an  Oracle Database

Deleting Database Files

2. Delete the following database files located in directory

C:\oracle\oradata\orcl:

Page 25: Creating an  Oracle Database

Modifying the Initialization Parameter File

• Copy:C:\ORACLE_BASE\admin\orcl\pfile\init.ora

• toC:\ORACLE_BASE\admin\prod\pfile\init.ora

-------------------------------------------------------------------• initsmpl.ora• ORACLE_BASE\ORACLE_HOME\admin\sample\pfile

Page 26: Creating an  Oracle Database

Creating and Starting an Oracle Service

• You are required to create and start an Oracle service only if you do one of the following:– Copy an existing database to a new database

and keep the old database– Create a new database when you have no other

database to copy

Using ORADIM Utility to Administer an Oracle

Instance

Page 27: Creating an  Oracle Database

Nos conectamos a la instancia creada:- sqlplus “/ as sysdba”- startup nomount pfile=d:\oracle\admin\prod\pfile\init.ora

Page 28: Creating an  Oracle Database

Putting the CREATE DATABASE Statement in a Script

Page 29: Creating an  Oracle Database

Running the CREATE DATABASE Script

1. Verify that the service is started in the Control Panel.

Check Status with: C:\> net START

List services: C:\> net START OracleServicePROD

2. Make PROD the current SID:• C:\> set ORACLE_SID=PROD

Page 30: Creating an  Oracle Database

Running the CREATE DATABASE Script

3. Start SQL*Plus from the command prompt, and connect to the database as SYSDBA

C:\> sqlplus / NOLOG

SQL> CONNECT / AS SYSDBA

4. Turn on spooling to save messages:

SQL> SPOOL script_name.log

5. Run script script_name.sql that you created

SQL> @C:\oracle\ora92\rdbms\admin\script_name.sql;

Page 31: Creating an  Oracle Database

1. Crear los directorios:– d:\oracle\admin\cg4

– d:\oracle\admin\cg4\bdump

– d:\oracle\admin\cg4\pfile

– d:\oracle\admin\cg4\udump

– d:\oracle\oradata\cg4

2. Copiar init.ora y editarlo con las nuevas rutas

3. Crear instancia:– ORADIM -NEW -SID cg4 -INTPWD cg4 -STARTMODE manual -PFILE "d:\oracle\admin\cg4\pfile\

init.ora"

4. Establecer la bd a trabajar:– Set ORACLE_SID = cg4

5. Conectarse al SQLPLUS– Sqlplus "/ as sysdba"

6. Levantar la BD no montada con el pfile init.ora– Startup nomount pfile=d:\oracle\admin\cg4\pfile\init.ora

Page 32: Creating an  Oracle Database

7. Crear Script de CREATE_DATABASE

CREATE DATABASE cg4

USER SYS IDENTIFIED BY dba

USER SYSTEM IDENTIFIED BY manager

Maxinstances 1

Maxloghistory 1

Maxlogfiles 10

Maxdatafiles 100

LOGFILE group 1 ('d:\oracle\oradata\cg4\redolog1a.dbf',

'd:\oracle\oradata\cg4\redolog1b.dbf') SIZE 10M,

group 2 ('d:\oracle\oradata\cg4\redolog2a.dbf',

'd:\oracle\oradata\cg4\redolog2b.dbf' ) SIZE 10M,

group 3 ('d:\oracle\oradata\cg4\redolog3a.dbf',

'd:\oracle\oradata\cg4\redolog3b.dbf' ) SIZE 10M

DATAFILE 'd:\oracle\oradata\cg4\system01.dbf' SIZE 200M

CHARACTER SET WE8ISO8859P1

national character set utf8

EXTENT MANAGEMENT LOCAL

sysaux datafile 'd:\oracle\oradata\cg4\sysaux01.dbf' size 50M autoextend on next 16M maxsize unlimited

undo tablespace UNDOTBS1

datafile 'd:\oracle\oradata\cg4\UNDOTBS1.dbf'

size 50M

DEFAULT TEMPORARY TABLESPACE tempts1

TEMPFILE 'd:\oracle\oradata\cg4\temp01.dbf'

SIZE 20M REUSE

/

Page 33: Creating an  Oracle Database

8. Ejecutar scripts de catalogos y diccionario de datos

ORACLE_HOME\rdbms\admin

START d:\oracle\ora92\rdbms\admin\CATALOG.sql

START d:\oracle\ora92\rdbms\admin\CATPROC.sql

START d:\oracle\ora92\rdbms\admin\catexp.sql