Choosing a database: use  The on clause

Chapter 8: Creating Databases and Tables

Creating a user database: create database

You can create a new database if a System Administrator has granted you permission to use create database. You must be using the master database when you create a new database. In many enterprises, a System Administrator creates all databases. The creator of a database is its owner. Another user who creates a database for you can transfer ownership of it using sp_changedbowner.

The Database Owner is responsible for giving users access to the database and for granting and revoking certain other permissions to users. In some organizations, the Database Owner is also responsible for maintaining regular backups of the database and for reloading it in case of system failure. The Database Owner can temporarily attain any other user’s permissions on a database by using the setuser command.

Because each database is allocated a significant amount of space, even if it contains only small amounts of data, you may not have permission to use create database.

The simplest form of create database is:

create database database_name

To create a new database called newpubs database, first verify you are using the master database rather than pubs2, and then type this command:

use master
create database newpubs 
drop database newpubs
use pubs2

A database name must be unique on Adaptive Server, and must follow the rules for identifiers described under “Identifiers”. Adaptive Server can manage up to 32,767 databases. You can create only one database at a time. The maximum number of segments for any database is 32.

Adaptive Server creates a new database as a copy of the model database, which contains the system tables that belong in every user database.

The creation of a new database is recorded in the master database tables sysdatabases and sysusages.

The full syntax of create database is in the Reference Manual.

This chapter describes all the create database options except with override. For information about with override, see the System Administration Guide.





Copyright © 2005. Sybase Inc. All rights reserved. The on clause

View this book as PDF