--1.以dba登陆
conn / as sysdba;
--2.创建directory并分配权限
create or replace directory D_OUTPUT as 'G:/test';
grant read,write on directory D_OUTPUT to scott;
grant execute on utl_file to scott;
--以scott用户连接数据库
conn scott/tiger;
declare
v_file_handle utl_file.file_type;
v_text varchar2(100):='Hello World!'; --存放文本
v_filename varchar2(30) := 'log_'||to_char(sysdate,'yyyymmdd')||'.log';
begin
v_file_handle:=utl_file.fopen('D_OUTPUT',v_filename,'a');
utl_file.put_line(v_file_handle,v_text);
utl_file.fflush(v_file_handle);
utl_file.fclose(v_file_handle);
end;
plsql操作文件
最新推荐文章于 2021-03-22 18:59:44 发布