從Oracle
對於DBA來說
以下一個例子用來說明外部表的用途
首先需要創建一個Directory
[oracle@jumper oracle]$ sqlplus/ as sysdba SQL*Plus: Release
Production on Sun Oct : : Copyright (c)
Oracle Corporation All rights reserved Connected to:
Oraclei Enterprise Edition Release Production
With the Partitioning option
JServer ReleaseProduction SQL> create or replace directory bdump
as /opt/oracle/admin/eygle/bdump ; Directory created
SQL> col DIRECTORY_PATH for a
SQL> col owner for a
SQL> select * from dba_directories;OWNER DIRECTORY_NAME DIRECTORY_PATH
SYS BDUMP /opt/oracle/admin/eygle/bdump
然後創建一個外部表:
SQL> create table alert_log ( text varchar( ) ) organization external ( type oracle_loader default directory BDUMP access parameters ( records delimited by newline nobadfile nodiscardfile nologfile ) location( alert_eygle log ) ) reject limit unlimited / Table created
然後我們就可以通過外部表進行查詢警告日志的內容:
SQL> select * from alert_log where rownum <; TEXT
Mon Jun: :
Starting ORACLE instance (normal)
Mon Jun: :
WARNING: EINVAL creating segment of sizex c
fix shm parameters in /etc/system or equivalent
LICENSE_MAX_SESSION =
LICENSE_SESSIONS_WARNING =
SCN scheme
Using log_archive_dest parameter default value
LICENSE_MAX_USERS =
SYS auditing is disabled
Starting up ORACLE RDBMS Version:
System parameters with nondefault values:
processes =
timed_statistics = TRUE
shared_pool_size =
large_pool_size =
java_pool_size =
control_files = /opt/oracle/oradata/eygle/controlctl
db_block_size =
db_cache_size =
db_cache_advice = ON
compatible =
db_file_multiblock_read_count=
fast_start_mttr_target =
log_checkpoints_to_alert = TRUE
undo_management = AUTO
undo_tablespace = UNDOTBS
undo_retention =
remote_login_passwordfile= EXCLUSIVE
db_domain =
instance_name = eygle
job_queue_processes =
hash_join_enabled = TRUE
background_dump_dest = /opt/oracle/admin/eygle/bdump
user_dump_dest = /opt/oracle/admin/eygle/udump
core_dump_dest = /opt/oracle/admin/eygle/cdump
sort_area_size =
db_name = eygle
open_cursors =
star_transformation_enabled= FALSE
query_rewrite_enabled = FALSE
pga_aggregate_target =
aq_tm_processes =
PMON started with pid=
DBWstarted with pid=
LGWR started with pid=
CKPT started with pid=
SMON started with pid=
RECO started with pid=
rows selected SQL>
如果我們需要查看數據庫中曾經出現過的ORA
SQL> select * from alert_log where text likeORA % ; TEXT
ORA: unable to extend temp segment by in tablespace TEMP
ORAsignalled during: alter database open
ORAsignalled during: alter database datafile online
ORA: scumnt: unable to lock file
ORAsignalled during: ALTER DATABASE MOUNT
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/users dbf
ORA: unable to obtain file status
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/users dbf TEXT
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf TEXT
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: alter database open
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORAsignalled during: alter database open
ORAsignalled during: alter database open
ORAsignalled during: ALTER DATABASE RECOVER database
ORAsignalled during: alter database open TEXT
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: ALTER DATABASE OPEN
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: ALTER DATABASE OPEN
ORAsignalled during: CREATE CONTROLFILE REUSE DATABASE EYGLE NORESETL
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: ALTER DATABASE MOUNT
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: IO error reading block from file (block # )
ORA: skgfdisp: attempt to do I/O beyond the range of the file
ORA: database file failed verification check TEXT
ORA: data file : /opt/oracle/oradata/eygle/system dbf
ORA: file is more recent than controlfile old controlfile
ORAsignalled during: alter database open
ORAsignalled during: ALTER DATABASE RECOVER database using backup cont
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: IO error reading block from file (block # )
ORA: skgfdisp: attempt to do I/O beyond the range of the file
ORA: file needs more recovery to be consistent
ORA: data file : /opt/oracle/oradata/eygle/system dbf
ORAsignalled during: alter database open resetlogs
ORAsignalled during: ALTER DATABASE RECOVER datafile TEXT
ORAsignalled during: ALTER DATABASE RECOVER database using backup cont
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: IO error reading block from file (block # )
ORA: skgfdisp: attempt to do I/O beyond the range of the file
ORA: file needs more recovery to be consistent
ORA: data file : /opt/oracle/oradata/eygle/system dbf
ORAsignalled during: alter database open resetlogs
ORAsignalled during: ALTER DATABASE RECOVER datafile
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: ALTER DATABASE OPEN
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf TEXT
ORA: IO error reading block from file (block # )
ORA: skgfdisp: attempt to do I/O beyond the range of the file
ORA: file needs more recovery to be consistent
ORA: data file : /opt/oracle/oradata/eygle/system dbf
ORAsignalled during: alter database open resetlogs
ORAsignalled during: alter database close
ORAsignalled during: CREATE CONTROLFILE REUSE DATABASE EYGLE NORESETL
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: alter database open
ORA: controlfile: /opt/oracle/oradata/eygle/control ctl
ORA: unable to obtain file status TEXT
ORAsignalled during: ALTER DATABASE MOUNT
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORA: CREATE DATABASE failed
ORA: error in opening file ?/rdbms/admin/sql bsq
ORA: sftopn: fopen error
ORA: error in opening file
ORAsignalled during: CREATE DATABASE eygle
ORAsignalled during: ALTER DATABASE MOUNT
ORAsignalled during: alter database open
ORAsignalled during: alter database mount
ORAsignalled during: ALTER DATABASE CLOSE NORMAL TEXT
ORAsignalled during: ALTER DATABASE MOUNT
ORAsignalled during: alter database mount
ORAsignalled during: ALTER DATABASE OPEN
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORAsignalled during: ALTER DATABASE OPEN
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORAsignalled during: alter database open TEXT
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORAsignalled during: ALTER DATABASE RECOVER database
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: alter database mount
ORAsignalled during: alter database create datafile /opt/oracle/produc
ORAsignalled during: alter database create datafile /opt/oracle/oradat
ORAsignalled during: ALTER DATABASE MOUNT
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf TEXT
ORA: unable to obtain file status
ORAsignalled during: ALTER DATABASE RECOVER database
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORAsignalled during: ALTER DATABASE RECOVER database using backup cont
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: ALTER DATABASE MOUNT
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/users dbf
ORA: unable to obtain file status TEXT
ORAsignalled during: ALTER DATABASE RECOVER database
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/users dbf
ORA: unable to obtain file status
ORAsignalled during: ALTER DATABASE RECOVER database using backup cont
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/users dbf
ORA: unable to obtain file status
ORAsignalled during: ALTER DATABASE RECOVER database using backup cont
ORAsignalled during: ALTER DATABASE RECOVER database using backup cont
ORAsignalled during: ALTER DATABASE RECOVER CONTINUE DEFAULT TEXT
ORAsignalled during: ALTER DATABASE RECOVER CONTINUE DEFAULT
ORAsignalled during: ALTER DATABASE RECOVER CANCEL
ORAsignalled during: alter database open
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: CREATE CONTROLFILE REUSE DATABASE EYGLE NORESETL
ORAsignalled during: alter database create datafile /opt/oracle/produc
ORAsignalled during: ALTER DATABASE MOUNT
ORA: cannot identify/lock data file see DBWR trace file
ORA: data file : /opt/oracle/oradata/eygle/eygle dbf
ORA: unable to obtain file status
ORAsignalled during: alter database open TEXT
ORAsignalled during: alter database open
ORAsignalled during: ALTER DATABASE MOUNT
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: alter database open
ORAsignalled during: ALTER TABLESPACE TEMP DEFAULT STORAGE (INITIAL M
ORAsignalled during: alter database close
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: alter database close normal
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: alter database dismount
ORAsignalled during: alter database open TEXT
ORAsignalled during: alter database open
ORAsignalled during: alter database open
ORAsignalled during: alter database open
ORAsignalled during: alter database open
ORAsignalled during: alter database close
ORAsignalled during: alter database close
ORAsignalled during: ALTER DATABASE CLOSE NORMAL
ORAsignalled during: alter database add logfile group
ORAsignalled during: alter database drop logfile group
rows selected SQL>
From:http://tw.wingwit.com/Article/program/Oracle/201311/17897.html