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 個字節的記錄。由於代理表只包含一列,每列的實際長度將由換行符的位置來確定