0% found this document useful (0 votes)
42 views

Chapter 1: Creating

This document discusses how to create proxy tables in SQL Anywhere that reference tables located in remote databases. It provides examples of creating proxy tables for Oracle, DB2, Excel spreadsheets, and another SQL Anywhere database. The proxy tables allow querying and modifying the remote table data through the local proxy table, while maintaining the actual data in the remote location.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Chapter 1: Creating

This document discusses how to create proxy tables in SQL Anywhere that reference tables located in remote databases. It provides examples of creating proxy tables for Oracle, DB2, Excel spreadsheets, and another SQL Anywhere database. The proxy tables allow querying and modifying the remote table data through the local proxy table, while maintaining the actual data in the remote location.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

34 Chapter 1: Creating

AT <remote_location>
<proxy_column_list> ::= "(" <proxy_column> { "," <proxy_column> } ")"
<proxy_column> ::= <column_name> <data_type> [ [ NOT ] NULL ]
In most cases CREATE EXISTING TABLE is used without a column list to cre-
ate a proxy table with exactly the same layout as the remote table. Here is an
example where an Oracle table, SCOTT.DEPT, is made available through a
proxy table called ora_dept:
CREATE SERVER ORASAMPLE CLASS 'ORAODBC' USING 'ORA SAMPLE';

CREATE EXTERNLOGIN DBA TO ORASAMPLE


REMOTE LOGIN system IDENTIFIED BY 'manager';

CREATE EXISTING TABLE ora_dept AT 'ORASAMPLE..SCOTT.DEPT';

SELECT * FROM ora_dept;


Heres a DB2 example where the remote table, ADMINISTRATOR.DEPART-
MENT, is queried through the proxy table, db2_department:
CREATE SERVER DB2DELL180 CLASS 'DB2ODBC' USING 'DB2 SAMPLE';

CREATE EXTERNLOGIN DBA TO DB2DELL180


REMOTE LOGIN db2admin IDENTIFIED BY 'secret';

CREATE EXISTING TABLE db2_department


AT 'DB2DELL180.SAMPLE.ADMINISTRATOR.DEPARTMENT';

SELECT * FROM db2_department;


It is possible to provide an explicit list of column names, data types, and
NULL/NOT NULL properties. You can use this list of column names to omit
columns, rearrange the order of the columns, and fiddle with the data types.
These changes do not affect the remote table, just the layout of the correspond-
ing proxy table. You cannot change the column names because thats how
columns are matched up between the remote and proxy tables. Here is an exam-
ple that creates another proxy table called etest2 based on the same Excel
spreadsheet created earlier; note that etest2 has a different layout than etest but
the INSERT still works:
CREATE EXISTING TABLE etest2
( pkey NUMERIC ( 10 ) NOT NULL,
fld1 VARCHAR ( 100 ) NOT NULL )
AT 'ASAEXCEL;c:\\temp\\asaexcel.xls;;test1';

INSERT INTO etest2 VALUES ( 2, 'A value that is longer than 20 characters.' );

SELECT * FROM etest2;


Here is a full, end-to-end example using two SQL Anywhere 9 databases. The
first database is the remote database and the second database contains the proxy
tables. On the first database a global permanent table t1 is created:
CREATE TABLE t1 (
pkey INTEGER NOT NULL,
c1 VARCHAR ( 20 ) NOT NULL,

You might also like