CREATE EXISTING TABLE statement

Description

Creates a new proxy table representing an existing object on a remote server.

Syntax

CREATE EXISTING TABLE [owner.]table_name 
[ ( column-definition, … ) ] 
AT 'location-string' 

Parameters

column-definition:

column-name data-typeNOT NULL ]

location-string:

remote-server-name.[db-name].[owner].object-name | remote-server-name;[db-name];[owner];object-name

Examples

Example 1

This example creates a proxy table named blurbs for the blurbs table at the remote server server_a:

CREATE EXISTING TABLE blurbs
( author_id id not null,
copy text not null)
AT 'server_a.db1.joe.blurbs'

Example 2

This example creates a proxy table named blurbs for the blurbs table at the remote server server_a. Sybase IQ derives the column list from the metadata it obtains from the remote table:

CREATE EXISTING TABLE blurbs
AT 'server_a.db1.joe.blurbs'

Example 3

This example creates a proxy table named rda_employee for the Employees table at the Sybase IQ remote server iqdemo:

CREATE EXISTING TABLE rda_employee
AT 'iqdemo..dba.Employees'

Usage

CREATE EXISTING TABLE is a variant of the CREATE TABLE statement. The EXISTING keyword is used with CREATE TABLE to specify that a table already exists remotely and that its metadata is to be imported into Sybase IQ. This establishes the remote table as a visible entity to its users. Sybase IQ verifies that the table exists at the external location before it creates the table.

Tables used as proxy tables cannot have names longer than 30 characters.

If the object does not exist (either host data file or remote server object), the statement is rejected with an error message.

Index information from the host data file or remote server table is extracted and used to create rows for the system table sysindexes. This defines indexes and keys in server terms and enables the query optimizer to consider any indexes that might exist on this table.

Referential constraints are passed to the remote location when appropriate.

If column definitions are not specified, Sybase IQ derives the column list from the metadata it obtains from the remote table. If column definitions are specified, Sybase IQ verifies the column definitions. Column names, data types, lengths, and null properties are checked for the following:

In a simplex environment, creating a proxy table which refers to a remote table on the same node is not allowed. In a multiplex environment, creating a proxy table which refers to the remote table defined within the multiplex is not allowed.

For example, in a simplex environment, if you try to create proxy table proxy_e which refers to base table Employees defined on the same node, then the CREATE EXISTING TABLE statement is rejected with an error message. In a multiplex environment, the CREATE EXISTING TABLE statement is rejected if you create proxy table proxy_e from any node (coordinator or secondary) which refers to remote table Employees defined within a multiplex.


Side effects

Automatic commit.

Standards

Permissions

Must have RESOURCE authority. To create a table for another user, you must have DBA authority.

See also

CREATE TABLE statement

Chapter 4, “Accessing Remote Data” and Chapter 5, “Server Classes for Remote Data Access” in the System Administration Guide: Volume 2