日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

oracle utl file grant,oracle中设置UTL_FILE_DIR参数

發(fā)布時間:2023/12/20 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle utl file grant,oracle中设置UTL_FILE_DIR参数 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

oracle中設(shè)置UTL_FILE_DIR參數(shù)

第一步:以管理員用戶登陸

如:conn??? sys/password@sid??? as??? sysdba

第二步:設(shè)置可操作目錄

需要指定utl_file包可以操作的目錄。在oracle??? 10g以前,可以用以下方法:

1、alter??? system??? set??? utl_file_dir='e:\utl'??? scope=spfile;

長路徑要使用'',如:utl_file_dir='c:\my??? temp';

2、在init.ora文件中,配置如下: UTL_FILE=E:\utl或者UTL_FILE_DIR=E:\utl

在oracle10g中建議用以下方法配置:CREATE??? DIRECTORY??? utl??? AS?? 'E:\utl';

第三步:授權(quán)給指定用戶,以便執(zhí)行utl_file

GRANT??? EXECUTE??? ON??? utl_file??? TO??? scott;

第四步:conn??? scott/tiger

就可以正常使用utl_file了。

第五步:文件I/O的實施

UTL_FILE包提供了很多實用的函數(shù)來進行I/O操作,主要有以下幾個函數(shù):

fopen:打開指定的目錄路徑的文件。

get_line:獲取指定文件的一行的文本。

put_line:向指定的文件寫入一行文本。

fclose:關(guān)閉指定的文件。

下面利用這些函數(shù),實現(xiàn)從文件取數(shù)據(jù),然后將數(shù)據(jù)寫入到相應(yīng)的數(shù)據(jù)庫中。

create??? or??? replace??? procedure??? loadfiledata(p_path??? varchar2,p_filename??? varchar2)??? as

v_filehandle??? utl_file.file_type;??? --定義一個文件句柄

v_text??? varchar2(100);??? --存放文本

v_name??? test_loadfile.name%type;

v_addr_jd??? test_loadfile.addr_jd%type;

v_region??? test_loadfile.region%type;

v_firstlocation??? number;

v_secondlocation??? number;

v_totalinserted??? number;

begin

if??? (p_path??? is??? null??? or??? p_filename??? is??? null)??? then

goto??? to_end;

end??? if;

v_totalinserted:=0;

v_filehandle:=utl_file.fopen(p_path,p_filename,'r');

loop

begin

utl_file.get_line(v_filehandle,v_text);

exception

when??? no_data_found??? then

exit;

end

v_firstlocation:=instr(v_text,',',1,1);

v_secondlocation:=instr(v_text,',',1,2);

v_name:=substr(v_text,1,v_firstlocation-1);

v_addr_jd:=substr(v_text,v_firstlocation+1,v_secondlocation-v_firstlocation-1);

v_region:=substr(v_text,v_secondlocation+1);

insert??? into??? test_loadfile

values??? (v_name,v_addr_jd,v_region);

commit;

end??? loop;

<>

null;

end??? loadfiledata;

來自 “ ITPUB博客 ” ,鏈接:http://blog.itpub.net/29519108/viewspace-2142124/,如需轉(zhuǎn)載,請注明出處,否則將追究法律責任。

總結(jié)

以上是生活随笔為你收集整理的oracle utl file grant,oracle中设置UTL_FILE_DIR参数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。