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

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements


Defines a new database space and creates the associated database file.

CREATE DBSPACE dbspace-name AS filename
  • dbspace-name

    Specify a name for the dbspace. This is not the actual database file name, which you specify using filename. dbspace-name is an internal name you can refer to, for example in statements and procedures. You cannot use the following names for a dbspace because they are reserved for predefined dbspaces: system, temporary, temp, translog, and translogmirror.

    An error is returned if you specify a value that contains a period (.).

  • filename

    Specify a name for the database file, including, optionally, the path to the file. If no path is specified, the database file is created in the same location (directory) as the main database file. If you specify a different location, the path is relative to the database server. The backslash ( \ ) is an escape character in SQL strings, so each backslash must be doubled.

    The filename parameter must be either a string literal or a variable.


The CREATE DBSPACE statement creates a new database file. When a database is created, it is composed of one file. All tables and indexes created are placed in that file. CREATE DBSPACE adds a new file to the database. This file can be on a different disk drive than the main file, which means that the database can be larger than one physical device.

If disk sandboxing is enabled, then database operations are limited to the directory where the main database file is located.

For each database, there is a limit of twelve dbspaces in addition to the main file.

Each object, such as a table or index, is contained entirely within one dbspace. The IN clause of the CREATE statement specifies the dbspace into which an object is placed. Objects are put into the system database file by default. You can also specify which dbspace tables are created in by setting the default_dbspace option before you create the tables.


You must have the MANAGE ANY DBSPACE system privilege.

Side effects

Automatic commit. Automatic checkpoint.

  • ANSI/ISO SQL Standard

    Not in the standard.


The following example creates a dbspace called libbooks in the c:\ directory. A subsequent CREATE TABLE statement creates a table called LibraryBooks in the libbooks dbspace.

AS 'c:\\library.db';
CREATE TABLE LibraryBooks (
  title char(100),
  author char(50),
  isbn char(30),
) IN libbooks;