久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機端+微網(wǎng)站+自適應(yīng)網(wǎng)頁多模板選擇-建站388元起價?。。?
當(dāng)前位置:主頁 > 網(wǎng)站建設(shè) > oracle中utl_file包讀寫文件操作實例學(xué)習(xí)建站知識

oracle中utl_file包讀寫文件操作實例學(xué)習(xí)建站知識

時間:2023-05-24 07:05:24 閱讀: 文章分類: 網(wǎng)站建設(shè) 作者: 網(wǎng)站技術(shù)員

導(dǎo)讀:1建站知識在oracle中utl_file包提供了一些操作文本文件的函數(shù)和過程,接下來和大家一起學(xué)習(xí)他的基本操作,感興趣的你可以參考網(wǎng)站seo優(yōu)化軟件seo網(wǎng)站排名優(yōu)化軟件。

網(wǎng)站seo優(yōu)化軟件seo網(wǎng)站排名優(yōu)化軟件在oracle中utl_file包提供了一些操作文本文件的函數(shù)和過程,學(xué)習(xí)了一下他的基本操作 1.創(chuàng)建directory,并給用戶授權(quán)

復(fù)制代碼 代碼如下:

--創(chuàng)建directory create or replace directory TESTFILE as '/home/oracle/zxx/test'; --給用戶授權(quán) grant read, write on directory TESTFILE to zxx;

詳細(xì)介紹 2.寫入操作

復(fù)制代碼 代碼如下:

---測試寫入 DECLARE filehandle utl_file.file_type; --句柄 begin filehandle := utl_file.fopen('TESTFILE','hello.txt','w'); --打開文件 utl_file.put_line(filehandle,'Hello Oracle!');--寫入一行記錄 utl_file.put_line(filehandle,'Hello World!'); utl_file.put_line(filehandle,'你好,胖子!'); utl_file.fclose(filehandle);--關(guān)閉句柄 end;

備注: fopen有一個參數(shù)max_linesize,下面是原文解釋 Maximum number of characters for each line, including the newline character, for this file (minimum value 1, maximum value 32767). If unspecified, Oracle supplies a default value of 1024. 3.讀取操作

復(fù)制代碼 代碼如下:

--測試讀取 set serveroutput on; DECLARE filehandle utl_file.file_type; filebuffer varchar2(500); begin filehandle := utl_file.fopen('TESTFILE','hello.txt','R'); IF utl_file.is_open(filehandle) THEN dbms_output.put_line('file is open!'); END IF; loop begin utl_file.get_line(filehandle,filebuffer); dbms_output.put_line(filebuffer); EXCEPTION WHEN no_data_found THEN exit ; WHEN OTHERS THEN dbms_output.put_line('EXCEPTION1:'||SUBSTR(SQLERRM, 1, 100)) ; end; end loop;百度seo網(wǎng)站優(yōu)化 utl_file.fclose(filehandle); IF utl_file.is_open(網(wǎng)站seo優(yōu)化課程filehandle) THENseo網(wǎng)站優(yōu)化 dbms_output.put_line('file is open!'); else dbms_output.put_line('file is close!'); END IF; utl_file.fcopy('TESTFILE', 'hello.txt', 'TESTFILE', 'hello.dat');--復(fù)制 utl_file.fcopy('TESTFILE', 'hello.txt', 'TESTFILE', 'hello2.dat'); utl_file.fcopy('TESTFILE', 'hello.txt', 'TESTFILE', 'hello.xls'); utl_file.frename('TESTFILE','hello.xls','TESTFILE','frenamehello.xls',TRUE);--重命名 utl_file.fremove('TESTFILE', 'hello2.dat');--刪除文件 EXCEPTION WHEN OTHERS THEN dbms_output.put_line('EXCEPTION2:'||SUBSTR(SQLERRM, 1, 100)) ; end;

4.判斷文件是否存在(讀,重命名,復(fù)制,刪除都要判斷文件是否存在)

復(fù)制代碼 代碼如下:

--判斷文件是否存在 DECLARE ex BOOLEAN;--文件是否存在 flen NUMBER;--文件長度? 這個地方不知道怎么理 (原文 file_length The length of the file in bytes. NULL if file does not exist.) bsize NUMBER;--文件大小 BEGIN utl_file.fgetattr('TESTFILE', 'hello.txt', ex, flen, bsize); IF ex THEN dbms_output.put_line('File Exists'); ELSE dbms_output.put_line('File Does Not Exist'); END IF; dbms_output.put_line('File Length: ' || TO_CHAR(flen)); dbms_output.put_line('Block Size: ' || TO_CHAR(bsize)); END fgetattr;

關(guān)鍵詞標(biāo)簽: 實例 標(biāo)簽

聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-24 ,文章oracle中utl_file包讀寫文件操作實例學(xué)習(xí)建站知識主要講述實例,標(biāo)簽,oracle中utl_file包讀寫文件操作實例網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_6302.html

我的IDC 網(wǎng)站建設(shè)技術(shù)SEOUC.COM
專注網(wǎng)站建設(shè),SEO優(yōu)化,小程序設(shè)計制作搭建開發(fā)定制網(wǎng)站等,數(shù)千家網(wǎng)站定制開發(fā)案例,網(wǎng)站推廣技術(shù)服務(wù)。
  • 5000+合作客服
  • 8年從業(yè)經(jīng)驗
  • 150+覆蓋行業(yè)
  • 最新熱門源碼技術(shù)文章

    主站蜘蛛池模板: 曲阳县| 集贤县| 海安县| 缙云县| 永济市| 鄂托克前旗| 乳山市| 湖北省| 鹤峰县| 西丰县| 桃园市| 英山县| 南投市| 营山县| 长兴县| 昭苏县| 茶陵县| 罗甸县| 柏乡县| 防城港市| 偏关县| 通州市| 光泽县| 揭西县| 西宁市| 五家渠市| 丰宁| 肥乡县| 延庆县| 涿州市| 安西县| 历史| 巩留县| 麻城市| 呼伦贝尔市| 平湖市| 松桃| 海南省| 洪湖市| 彰武县| 仁寿县|