1. Understanding Oracle External Tables
External table Definition: The structure is stored in the data dictionary, and the table data is placed in the OS file in the table
Role: Querying the database for OS file data and loading OS file data into the database
Differences from other tables: DML operations cannot be performed on external tables and indexes on external tables can only be performed with the Select exercise
2. Build a simple external table 1. Build a file on the OS
Because the external table is primarily to view files on the OS, first build a file on the OS
Mkdir-p/oracle/ext
Vi/oracle/ext/ext.dat
10,20,30
40,50,60
70,80,90
2. Grant user permissions and create directory objects
Here we first build a new user
Create user test identified by ' 123 ' default tablespace test quota unlimited on test; |
User authorization
Sql> Grant Create any directory to test; |
Create a directory Object
Sql> Conn test/123 Connected. Sql> Create directory ext as '/oracle/ext '; Directory created. |
3. Create an external table
sql> Create table exttable (
ID number,name varchar2 (a), I number
) Organization External
(Type Oracle_loader
Default directory Ext
Access Parameters
(Records delimited by newline
Fields terminated by ', '
) Location (' Ext.dat ')
);
4. Test
Sql> select * from Exttable; ID NAME I ---------- ---------- ---------- 10 20 30 40 50 60 90 |
Test is successful, visible in the database can query the OS file data
Current 1/2 page
12 Next read the full text