1.配置允许访问文件系统
exec sp_configure 'enable file access', 1
2.创建代理表实现访问,前提是ASE进程对目录有访问或者创建新文件的权限
--创建代理表实现访问
create proxy_table TB_SYS_TMP external directory at '/tmp/test/'
3.应用
--查询
select * from TB_SYS_TMP
id,filename,size,filetype,access,uid,gid,atime,mtime,ctime,content
2054000000339330,'a.txt',20,'REG','-rw-r--r--','root','root',2014-06-17 13:55:24.0,2014-06-17 13:55:35.0,2014-06-17 13:55:35.0,0x746573742070726f7879206469726563746f720a
--创建文件
insert into TB_SYS_TMP(filename,content) values('b.txt','this is b.txt')
--创建新目录
insert into TB_SYS_TMP(filename,filetype) values('newdir','DIR')
4.验证
[root@sybaseHost test]# ls -l
total 12
-rw-r--r-- 1 root root 20 Jun 17 13:55 a.txt
-rw-r----- 1 root root 13 Jun 17 14:05 b.txt
drwxr-x--- 2 root root 4096 Jun 17 14:06 newdir
5.通过;R实现递归
create proxy_table TB_SYS_TMP external directory at '/tmp/test/;R'
select * from TB_SYS_TMP
6.指定代理表字段
create existing table errorlog
(
record varchar(512) null
)
external file at "/usr/sybase/ASE15_0/install/errorlog"
在这种情况下,将返回最长为 512 个字节的记录。由于代理表只包含一列,每列的实际长度将由换行符的位置来确定