Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Reference » SQL Statements

CREATE SCHEMA statement Next Page

CREATE SERVER statement


Use this statement to create a remote server.

Syntax 1

CREATE SERVER server-name
CLASS server-class
USING connection-info
[ READ ONLY ]

server-class :
SAJDBC | ASEJDBC | SAODBC | ASEODBC
| DB2ODBC | MSSODBC | ORAODBC | ODBC

connection-info :
{ computer-name:port-number [/dbname ] | data-source-name | sqlanywhere-connection-string }

Syntax 2

CREATE SERVER server-name
CLASS 'DIRECTORY'
USING using-clause

using-clause :
ROOT=path
[ ;SUBDIRS=n ]
[ ;READONLY={ YES | NO } ]

Parameters

CLASS clause    Specifies the server class you want to use for a remote connection. Server classes contain detailed server capability information. If you are using NetWare, only the SAJDBC class is supported. The DIRECTORY class is used in Syntax 2 to access a directory on the local computer.

USING clause    In Syntax 1, the USING clause supplies a connection string for the database server. The appropriate connection string depends on the driver being used, which in turn depends on the server-class.

If a JDBC-based server class is used, the USING clause is of the form hostname:portnumber [/dbname], where:

If an ODBC-based server class is used, the USING clause is the data-source-name. The data-source-name is the ODBC Data Source Name.

For SQL Anywhere remote servers (SAJDBC or SAODBC server classes), the connection-info parameter can be any valid SQL Anywhere connection string. You can use any SQL Anywhere connection parameters. For example, if you have connection problems, you can include a LOG connection parameter to troubleshoot the connection attempt.

For more information on SQL Anywhere connection strings, see Connection parameters.

On Unix platforms, you need to reference the ODBC driver manager as well. For example, using the supplied iAnywhere Solutions ODBC drivers, the syntax is as follows:

USING 'driver=SQL Anywhere 10;dsn=my_dsn'

In Syntax 2, the USING clause specifies the following values for the local directory:

Remarks

When you create a remote sever, it is added to the ISYSSERVER system table.

Syntax 1    The CREATE SERVER statement defines a remote server.

For more information on server classes and how to configure a server, see Server Classes for Remote Data Access.

Syntax 2    The CREATE SERVER statement lets you create a directory access server that accesses the local directory structure on the computer where the database server is running. You must create an external login for each database user that needs to use the directory access server. On Unix, the database server runs as a specific user, so file permissions are based on the permissions granted to the database server user.

For more information about directory access servers, see Using directory access servers.

Permissions

Must have DBA authority to execute this command.

Not supported on Windows CE.

Side effects

Automatic commit.

See also
Standards and compatibility
Example

The following example creates a SQL Anywhere remote server named testsa, located on the computer named apple and listening on port number 2638, use:

CREATE SERVER testsa
CLASS 'SAJDBC'
USING 'apple:2638';

The following example creates a remote server for the JDBC-based Adaptive Server named ase_prod. Its computer name is banana and its port number is 3025.

CREATE SERVER ase_prod
CLASS 'asejdbc'
USING 'banana:3025';

The following example creates a remote server for the Oracle server named oracle723. Its ODBC Data Source Name is oracle723.

CREATE SERVER oracle723
CLASS 'oraodbc'
USING 'oracle723';

The following example creates a directory access server that only sees files within the directory c:\temp:

CREATE SERVER diskserver0
CLASS 'directory'
USING 'root=c:\temp';
CREATE EXTERNLOGIN DBA TO diskserver0;
CREATE EXISTING TABLE diskdir0 AT 'diskserver0;;;.';

-- Get a list of those files.
SELECT permissions, file_name, size FROM diskdir0;

The following example creates a directory access server that sees nine levels of directories:

-- Create a directory server that sees 9 levels of directories.
CREATE SERVER diskserver9
CLASS 'directory'
USING 'ROOT=c:\temp;SUBDIRS=9';
CREATE EXTERNLOGIN DBA TO diskserver9;
CREATE EXISTING TABLE diskdir9 AT 'diskserver9;;;.';