Solution 2: Use an Oracle External table to view related alarm information

Source: Internet
Author: User
Tags table definition

If you want to better use Oracle External tables to view related alarm information, you must first understand the concept of Oracle External tables and the differences with other tables, to create a relatively simple Oracle External table (mainly depends on the operation process), finally we use the External table to view the Oracle alarm log.

1. Understand Oracle External tables

External table definition: The structure is stored in the data dictionary, and the table data is stored in the OS file.

Purpose: query the OS file data in the database and load the OS file data to the database.

Differences from other tables: you cannot perform DML operations on External tables, nor create indexes on External tables. You can only perform select operations.

2. Create a simple External table

1. Create an OS file

Because Oracle External tables are mainly used to view files on the OS, a file is first created on the OS.

 
 
  1. mkdir -p /Oracle/ext   
  2. vi /Oracle/ext/ext.dat   
  3. 10,20,30   
  4. 40,50,60   
  5. 70,80,90  

2. Grant user permissions and create directory objects

Create a new user

 
 
  1. create user test identified by “123” default tablespace test quota unlimited on test;  

User authorization

 
 
  1. SQL> grant create any directory to test;  

Create a directory object

 
 
  1. SQL> conn test / 123   
  2. Connected.   
  3. SQL> create directory ext as '/Oracle/ext';   
  4. Directory created.  

3. Create an Oracle External table

 
 
  1. SQL> create table exttable(   
  2. id number,name varchar2(10),i number   
  3. )organization external   
  4. (type Oracle_loader   
  5. default directory ext   
  6. Access parameters   
  7. (records delimited by newline   
  8. fields terminated by ','   
  9. )location('ext.dat')   
  10. );  

4. Test

 
 
  1. SQL> select * from exttable;   
  2. ID NAME I   
  3. ---------- ---------- ----------   
  4. 10 20 30   
  5. 40 50 60   
  6. 70 80 90  

The test is successful. You can view the OS file data in the database.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.