zoukankan      html  css  js  c++  java
  • Use utl-file to operate file in Oracle

    The below is about utl_file operation:

    First, you should make a directory at the path that you wish:

    [jeffreyxu@rat167 ~]$ mkdir test_dir
    

    If you want anyone has the privileges read, write and execute, you can use the command to add these privileges to this directory.

    [jeffreyxu@rat167 ~]$ chmod 777 test_dir 
    


    Use sys account log in oracle, and the next commands are entered by sys

    [jeffreyxu@rat167 ~]$ rlwrap sqlplus sys/111111@localhost:1522/xe as sysdba;
    
    SQL*Plus: Release 12.1.0.1.0 Production on Mon Dec 7 14:35:22 2015
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
    

     
      Make a alias for the directory you have found

    SQL> create or replace directory BLOBDIR as '/sandbox/test_dir';
    
    Directory created.
    

       Add read and write privileges to the directory above on your account

     SQL> grant read,write on directory BLOBDIR to GDB;
    
    Grant succeeded.
    


      Check is there this directory:

    SQL> select * from ALL_DIRECTORIES;
    
    OWNER                   DIRECTORY_NAME
    ------------------------------ ------------------------------
    DIRECTORY_PATH
    --------------------------------------------------------------------------------
    SYS                   TEST_DIR
    /sandbox/project/modified03-cci-09abby/match_acct_report
    
    SYS                   XMLDIR
    /u01/app/oracle/product/11.2.0/xe/rdbms/xml
    
    SYS                   DATA_PUMP_DIR
    /u01/app/oracle/admin/XE/dpdump/
    
    
    OWNER                   DIRECTORY_NAME
    ------------------------------ ------------------------------
    DIRECTORY_PATH
    --------------------------------------------------------------------------------
    SYS                   BLOBDIR
    /sandbox/test_dir
    

     
      Add execute privilege to utl_file on useraccount

    SQL> grant execute on utl_file to GDB;
    
    Grant succeeded.
    
  • 相关阅读:
    Python 01 Python的安装和配置
    Python 04 Geany的安装和配置
    Python 02 编写代码
    Python 03 pip 的安装和使用
    开源项目 12 ServiceStack.OrmLite
    北京第二天
    exit
    北京第一天
    关于扩展欧几里得算法和逆元
    正妹吃月饼
  • 原文地址:https://www.cnblogs.com/Jeffrey-xu/p/5033637.html
Copyright © 2011-2022 走看看