Vous êtes sur la page 1sur 1

Chapter 1: Creating 33

1.14.3 CREATE Remote and Proxy Tables


The CREATE TABLE ... AT command creates both the remote and proxy tables
at the same time. You must specify a list of column definitions and other proper-
ties just like with a global permanent table, with the exception that this list will
also be sent to the remote server to create a table there. You must also provide a
string literal pointing to the remote server and specifying the table name on that
server.
<create_remote_and_proxy_table> ::= CREATE TABLE [ <owner_name> "." ] <table_name>
<table_element_list>
AT <remote_location>
<remote_location> ::= literal 'server_local_name;[db_name];[owner];object_name'
The remote location string consists of four components separated by semicolons
or periods, with semicolons necessary when the components themselves contain
periods. The first component is always the local name for the remote server as
defined by the CREATE SERVER command, and the last component is always
the table, view, or object name on that server. The other two components depend
on the remote server. For example, with Excel the second component is the file
specification, the third component is omitted, and the last component is the
sheet name. With DB2, SQL Anywhere, and most other relational databases, the
second, third, and fourth components are database name, owner name, and table
or view name respectively. Oracle is an exception where the database name is
omitted.
Here is an example that creates a new Excel spreadsheet called test1 inside
a workbook asaexcel.xls. A row is inserted and retrieved through a proxy table
called etest. Note that CREATE EXTERNLOGIN is not required.
CREATE SERVER ASAEXCEL CLASS 'ODBC' USING 'EXCEL SAMPLE';

CREATE TABLE etest


( pkey INTEGER NOT NULL,
fld1 VARCHAR ( 20 ) NOT NULL,
fld2 INTEGER NOT NULL )
AT 'ASAEXCEL;c:\\temp\\asaexcel.xls;;test1';

INSERT INTO etest VALUES ( 1, 'Hello, World', 9 );

SELECT * FROM etest;

Tip: When creating an Excel ODBC DSN to use with proxy tables, you must
specify a dummy workbook file specification with the ODBC Administrator
Select Workbook button. This file specification is ignored by CREATE TABLE,
and the one specified in the remote location string is used instead.

Tip: Most remote servers have to be running before you can create a proxy
table, but thats not true of Excel.

1.14.4 CREATE EXISTING TABLE


The CREATE EXISTING TABLE command retrieves the definition of an exist-
ing table on the remote database and uses that definition to create a proxy table.
<create_proxy_table> ::= CREATE EXISTING TABLE [ <owner_name> "." ] <table_name>
[ <proxy_column_list> ]

Vous aimerez peut-être aussi