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 Usage » Working with Database Objects » Working with databases » Creating a database

Creating databases (Sybase Central) Next Page

Creating databases (SQL)

In Interactive SQL, use the CREATE DATABASE statement to create databases. You need to connect to an existing database before you can use this statement.

To create a new database (SQL)
  1. Start a database server named sample.

    dbeng10 -n sample
  2. Start Interactive SQL.

  3. Connect to an existing database. If you don't have a database then you can connect to the utility database utility_db. See Connecting to the utility database.

  4. Execute a CREATE DATABASE statement.

For more information, see CREATE DATABASE statement.


Create a database file in the c:\temp directory with the file name temp.db.

CREATE DATABASE 'c:\\temp\\temp.db';

The directory path is relative to the database server. You set the permissions required to execute this statement on the server command line, using the -gu option. The default setting requires DBA authority.

The backslash is an escape character in SQL, and must be doubled in some cases. The \x and \n sequences can be used to specifying hexadecimal and newline characters. Letters other than n and x do not have any special meaning if they are preceded by a backslash. Here are some examples where this is important.

CREATE DATABASE 'c:\\temp\\\x41\x42\x43xyz.db';

The initial \\ sequence represents a backslash. The \x sequences represent the characters A, B, and C, respectively. The file name here is ABCxyz.db.

CREATE DATABASE 'c:\temp\\nest.db';

To avoid having the \n sequence interpreted as a newline character, the backslash is doubled.

For more information, see Strings.