Creating a dbspace

You create a new database file, or dbspace, either from Sybase Central, or using the CREATE DBSPACE statement. The database file for a new dbspace may be on the same disk drive as the main file or on another disk drive. You must have DBA authority to create dbspaces.

For each database, you can create up to twelve dbspaces in addition to the main dbspace. You can specify the dbspace in which an object is stored by setting the default_dbspace database option.

Placing tables in dbspaces

A newly-created dbspace is empty. When you create a new table or index you can place it in a specific dbspace with an IN clause in the CREATE statement or set the default_dbspace option before creating the table. If you don't specify an IN clause, and don't change the setting of the default_dbspace option, the table appears in the SYSTEM dbspace.

Each table is entirely contained in the dbspace it is created in. By default, indexes appear in the same dbspace as their table, but you can place them in a separate dbspace by supplying an IN clause as part of the CREATE statement.

To create a dbspace (Sybase Central)

  1. Open the Dbspaces folder for the database.

  2. From the File menu, choose New » Dbspace.

    The Create Dbspace Wizard appears.

  3. Follow the instructions in the wizard.

    The new dbspace appears in the Dbspaces folder.

To create a dbspace (SQL)

  • Execute a CREATE DBSPACE statement.

Examples

The following command creates a new dbspace called MyLibrary in the file library.db in the same directory as the main file:

CREATE DBSPACE MyLibrary
AS 'library.db';

The following command creates a table LibraryBooks and places it in the MyLibrary dbspace.

CREATE TABLE LibraryBooks (
title CHAR(100),
author CHAR(50),
isbn CHAR(30)
) IN MyLibrary;

The following commands create a new dbspace named MyLibrary, set the default dbspace to the MyLibrary dbspace, and then create the LibraryBooks table in the MyLibrary dbspace.

CREATE DBSPACE MyLibrary
AS 'e:\\dbfiles\\library.db';
SET OPTION default_dbspace = 'MyLibrary';
CREATE TABLE LibraryBooks (
  title CHAR(100),
  author CHAR(50),
  isbn CHAR(30),
);
See also