oracle ora工具,ORACLE 常用工具包之03(orasftp)

安装jar 包

[oracle@XAG143 javaclass]$ ls

ora-sftp-1.3.jar

[oracle@XAG143 javaclass]$ loadjava -r -f -o -user admin/xag123@192.168.40.143:1521/MYPDB1 ora-sftp-1.3.jar

发布 OraSFTP_Package.sql 文件

检查安装情况

SQL> select ORA_SFTP.VERSION from dual;

VERSION

----------------------------------------------------------

1.3.2.1

#returns TRUE if this is an evaluation version

SQL> select ORA_SFTP.IS_TRIAL_VERSION from dual;

IS_TRIAL_VERSION

----------------

1

grant permissions

SQL> call dbms_java.grant_permission('ADMIN', 'SYS:java.net.SocketPermission', '192.168.40.143:22', 'connect,resolve');

4 测试(显示当前目录)

DECLARE

connection_id NUMBER;

remote_ssh_port NUMBER := 22;

username VARCHAR2(200);

password VARCHAR2(200);

BEGIN

username:= 'oracle';

password:= '123456';

connection_id := ORA_SFTP.CONNECT_HOST('192.168.40.143', remote_ssh_port, username, password);

dbms_output.put_line('Current folder is ' || ORA_SFTP.CURRENT_DIRECTORY(connection_id));

dbms_output.put_line('Current folder is ' || ORA_SFTP.PWD(connection_id));

END;

#输出

Current folder is /home/oracle

Current folder is /home/oracle

4.1 测试(LIST)

DECLARE

connection_id NUMBER;

remote_ssh_port NUMBER := 22;

username VARCHAR2(200);

password VARCHAR2(200);

files ORA_SFTP_FILES_LIST;

BEGIN

username:= 'oracle';

password:= '123456';

connection_id := ORA_SFTP.CONNECT_HOST('192.168.40.143', remote_ssh_port, username, password);

dbms_output.put_line('Current folder is ' || ORA_SFTP.CURRENT_DIRECTORY(connection_id));

dbms_output.put_line('Current folder is ' || ORA_SFTP.PWD(connection_id));

files :=ORA_SFTP.LIST(connection_id); -- retrieves in current folder

--print the listed file names

FOR i IN files.first .. files.last loop

dbms_output.put_line('file(' || i || ') = ' || files(i));

END loop;

ORA_SFTP.DISCONNECT_HOST(connection_id);

EXCEPTION

WHEN OTHERS THEN

DBMS_OUTPUT.PUT_LINE('General error : ' || SQLERRM );

END;

#输出

Current folder is /home/oracle

Current folder is /home/oracle

file(1) = .

file(2) = ..

file(3) = .bash_history

file(4) = .bash_logout

file(5) = .bash_profile

file(6) = .bashrc

file(7) = .oracle_jre_usage

file(8) = .sqlcl

file(9) = .viminfo

file(10) = javaclass

file(11) = my_dir

file(12) = setup

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值