IBConsole - General Procedures

From InterBase
Jump to: navigation, search

Go Up to IBConsole

This section covers additional general procedures when working with databases:

How to Alter Databases
How to Drop Databases
How to Extract Metadata from Existing Databases

How to Alter Databases

A database can be altered by its creator, the database administrator (SYSDBA), or another user designated by the SYSDBA.

ALTER DATABASE requires exclusive access to the database.

The syntax for ALTER DATABASE is:

ALTER {DATABASE | SCHEMA}
ADD <add_clause>;
<add_clause> = 
FILE "<filespec>" <fileinfo> [<add_clause>]
<fileinfo> = LENGTH [=] int [PAGE[S]] | STARTING [AT [PAGE]] int [<fileinfo>]

The complete syntax of ALTER DATABASE is in the Data Definition Guide.

Example
Use ALTER DATABASE to add one or more secondary files to an existing database. Secondary files are useful for controlling the growth and location of a database. They permit database files to be spread across storage devices, but must remain on the same node as the primary database file.

You must specify a range of pages for each file either by providing the number of pages in each file, or by providing the starting page number for the file. The following statement adds two secondary files to the currently connected database:

ALTER DATABASE 
               ADD FILE "employee.gd1" 
               STARTING AT PAGE 10001
                               LENGTH 10000
               ADD FILE "employee.gd2" 
                               LENGTH 10000;

How to Drop Databases

DROP DATABASE is the command that deletes the database currently connected to, including any associated shadow and log files. Dropping a database deletes any data it contains. A database can be dropped by its creator, the database administrator (SYSDBA), or another user designated by the SYSDBA.

The following statement deletes the current database:

DROP DATABASE;

How to Extract Metadata from Existing Databases

ISQL enables you to extract data definition statements from a database and store them in an output file. All keywords and objects are extracted into the file in uppercase.

The output file enables users to:

  • Examine the current state of a database's system tables before planning alterations. This is especially useful when the database has changed significantly since its creation.
  • Create a database with schema definitions that are identical to the extracted database.
  • Make changes to the database, or create a new database source file with a text editor.

Next