原創 OCILIB操作bfile欄位

2022-08-29 23:45:24 字數 2592 閱讀 4900

(1)、基於服務端 vs 基於客戶端

檔案的路徑都是相對於服務端目錄的路徑。

(2)、如何建立乙個目錄物件?

為了建立目錄,必須具有dba角色或者賦予了create any directory許可權。

示例:window平台

connect system/manager 

create or replace directory my_dir as'

d:\datapump';

create or replace directory my_logdir as'

e:\logs';

grant read, write on directory my_dir to scott;

grant read, write on directory my_logdir to scott;

unix平台

connect system/manager 

grant create any directory to scott;

connect scott/tiger

create or replace directory my_dir as'

/usr/datapump';

create or replace directory my_logdir as'

/usr/logs

';

如果普通使用者被賦予了create any directory許可權,那麼使用者就自動具備目錄的read和write許可權。

注意:create directory語句不會建立磁碟的真實目錄,如果目錄是無效的,資料幫浦作業會報錯:

ora-39002

: invalid operation

ora-39070

: unable to open the log file.

ora-29283

: invalid file operation

ora-06512: at "

sys.utl_file

", line 475

ora-29283: invalid file operation

(3)、如何查詢可用的目錄?

可以使用如下sql查詢具有read和write許可權的目錄:

select directory_name, grantee, privilege 

from user_tab_privs t, all_directories d

where t.table_name(+)=d.directory_name

order by

1,2,3;

create table bfile_test

(code number(6),

value bfile

)

#include "

ocilib.h

"int main(void)

cn = oci_connectioncreate("

hisd

", "

ha2", "

peidian

", oci_session_default);

if (!cn)

st =oci_statementcreate(cn);

if (!st)

file =oci_filecreate(cn, oci_cfile);

if (!file)

if (!oci_filesetname(file, "

mydir

", "

bbbb.txt"))

/*check if faile exists

*/if

(oci_fileexists(file))

else

/*bind for inserting into table

*/if(!oci_prepare(st, "

insert into bfile_test(code, value) values (1, :bfile)"))

if(!oci_bindfile(st, "

:bfile

", file))

if(!oci_execute(st))

if(!oci_commit(cn))

/*free local file object

*/oci_filefree(file);

printf(

"insert ok\n");

#if 0

/*fetch bfile data from table

*/oci_executestmt(st,

"select code, value from bfile_test");

rs =oci_getresultset(st);

while

(oci_fetchnext(rs))

oci_fileclose(file);

}oci_cleanup();

#endif

return

exit_success;

}

原創 mac classpath 操作觀止

總旨 1.mac 下面路徑的分隔符時候 英文冒號 2.export 用來新增 classpath,並可講新定義的路徑合併到 path 中 path 是系統內建並頻繁使用的 3.terminal 中更改過路徑配置後,需要重啟乙個 terminal 視窗,路徑配置才會生效 4.path 中一段段的路徑是...

原創 INI檔案的讀寫操作

ini 檔案的讀寫操作 在程式開發中,很多人會把引數儲存為 ini檔案格式,ini檔案的乙個好處是可以儲存為乙個結構體主結構,如 user name test userid test server serverip 127.0.0.1 serverport 80 很方便也很容易區分,而且不同節點下的...

原創 HBase學習筆記(2) 基本操作

其中test是表名,cf是列族。該錶只建立了乙個列族。格式 put 上面插入了兩條記錄。row key1和row key2是主鍵,row key1記錄有兩個欄位field1和field2,字段值分別是value1和value2。而row key2記錄只插入了乙個欄位field1,取值是value1。...