File access

Another class of proxy tables allowed in Adaptive Server enables SQL access to individual files within a file system. The supported syntax is:

create proxy_table <table_name>
	external file at " pathname" [column delimiter “<string>”]

When this command is used, a proxy table with one column (named “record”, type varchar(255)) is created. It is assumed in this case that the contents of the file are readable characters, and that individual records within the file are separated by the newline (\n) character.

You can also specify your own column names and datatypes, using the create [existing] table command:

create existing table fname (
	column1		int  null,
	column2		datetime null,
	column3		varchar(1024)  null
	etc. etc.
) external file at "pathname" [column delimiter “<string>”]

Columns may be any datatype except text, image, or a Java ADT. The use of the existing keyword is optional, and has no effect on the processing of the statement. If the file referenced by path name does not exist, it is created. If it does exist, its contents are not overwritten. There is no difference in behavior between the create table and create existing table commands.

When a proxy table is mapped to a file, these assumptions about the file and its contents are made:

With proxy tables mapped to files, you can:

Only the select, insert, and truncate table statements are supported for file access. update and delete result in errors if the file proxy is the target of these commands.

When inserting values into a file, all datatypes are first converted to char values and then delimited by the column delimiter.

WARNING!  truncate table sets the file size to 0.

Trace flag 11206 is used to log messages to the error log. These messages contain information about the stages of query processing that are involved with file access.