Op Guide
Op Guide
Op Guide
InterBase 2020
Update 1
Operations Guide
© 2020 Embarcadero Technologies, Inc. Embarcadero, the Embarcadero Technologies logos, and all other
Embarcadero Technologies product or service names are trademarks or registered trademarks of Embar-
cadero Technologies, Inc. All other trademarks are property of their respective owners.
Embarcadero Technologies, Inc. is a leading provider of award-winning tools for application developers.
Embarcadero enables developers to design systems right, build them faster and run them better, regard-
less of their platform or programming language. Ninety of the Fortune 100 and an active community of
more than three million users worldwide rely on Embarcadero products to increase productivity, reduce
costs and accelerate innovation. The company's flagship tools include: Embarcadero® RAD Studio™, Del-
phi®, C++Builder®, JBuilder®, and the IoT Award winning InterBase®. Founded in 1993, Embarcadero
is headquartered in Austin, with offices located around the world. Embarcadero is online at www.embar-
cadero.com.
April, 2020
Table of Contents
iii
Table of Contents
5. System Table Security ............................... 71 10.3. Setting the Sweep Interval ................. 103
6. SQL Privileges ............................................. 73 10.4. Disabling Automatic Sweeping .......... 103
7. Groups of Users ......................................... 73 10.5. Performing an Immediate Database
8. Other Security Measures ........................... 74 Sweep .......................................................... 103
9. User Administration with IBConsole ........ 75 11. Configuring the Database Cache ......... 104
10. User Administration With the InterBase 11.1. Default Cache Size Per Database ........ 104
API .................................................................... 78 11.2. Default Cache Size Per isql Connec-
11. Using gsec to Manage Security ............. 78 tion ............................................................... 105
11.1. Running gsec Remotely ........................ 78 11.3. Setting Cache Size in Applications ..... 105
11.2. Running gsec with Embedded 11.4. Default Cache Size Per Server ............ 105
Database User Authentication ..................... 79 11.5. Verifying Cache Size ........................... 105
11.3. Using gsec Commands ........................ 79 12. Forced Writes vs. Buffered Writes ........ 106
11.4. Using gsec from a Windows Command 13. Validation and Repair ........................... 106
Prompt ........................................................... 81 13.1. Validating a Database ........................ 107
12. Using gsec to Manage Database 13.2. Repairing a Corrupt Database ........... 109
Alias .................................................................. 82 14. Shutting Down and Restarting Databas-
13. gsec Error Messages ............................... 82 es .................................................................... 110
14.1. Shutting Down a Database ................. 110
DATABASE CONFIGURATION AND MAIN- 14.2. Restarting a Database ........................ 112
TENANCE ....................................................... 84 15. Limbo Transactions ............................... 112
15.1. Recovering Transactions ..................... 113
1. Database Files ............................................ 84
16. Viewing the Administration Log .......... 115
1.1. Database File Size .................................. 84
16.1. gfix Command-line Tool ...................... 115
1.2. External Files .......................................... 85
16.2. gfix Error Messages ............................ 117
1.3. Temporary Files ..................................... 86
16.3. gfix Fixing a database ......................... 118
1.4. File Naming Conventions ...................... 86
1.5. Multifile Databases ................................ 87 DATABASE BACKUP AND RESTORE .......... 119
1.6. Networked File Systems ........................ 88
2. On-disk Structure (ODS) ........................... 89 1. About InterBase backup and restore op-
3. Read-write and Read-only Databas- tions ............................................................... 119
es ...................................................................... 89 1.1. InterBase backup and restore tools ...... 119
3.1. Read-write Databases ........................... 89 1.2. The difference between logical and
3.2. Read-only Databases ............................ 89 physical backups ......................................... 120
4. Creating Databases .................................... 91 1.3. Database ownership ............................. 121
4.1. Database Options .................................. 92 2. Performing backups and restores using
5. Dropping Databases .................................. 93 the gbak command ..................................... 121
6. Backup File Properties ............................... 93 2.1. General guidelines for using gbak ....... 121
7. Removing Database Backup Files ............ 94 2.2. Initiating multi- and single-file back-
8. Shadowing .................................................. 94 ups ............................................................... 122
8.1. Tasks for Shadowing .............................. 94 2.3. Creating incremental backups ............ 124
8.2. Advantages of Shadowing ................... 95 2.4. Restoring a database with gbak ......... 129
8.3. Limitations of Shadowing ..................... 95 2.5. Using gbak with InterBase Service Man-
8.4. Creating a Shadow ............................... 95 ager ............................................................. 135
8.5. Activating a Shadow ............................. 99 2.6. The user name and password ............ 136
8.6. Dropping a Shadow ............................. 99 2.7. Some backup and restore exam-
8.7. Adding a Shadow File ........................... 99 ples .............................................................. 137
9. Setting Database Properties ..................... 99 2.8. gbak error messages ........................... 138
9.1. Alias Tab ................................................ 100 3. Performing backups and restores using
9.2. General Tab .......................................... 100 IBConsole ....................................................... 141
10. Sweep Interval and Automated House- 3.1. Performing a full backup using IBCon-
keeping .......................................................... 101 sole ............................................................... 141
10.1. Fast Sweep ........................................... 101 3.2. Performing an incremental backup us-
10.2. Overview of Sweeping ....................... 102 ing IBConsole .............................................. 146
iv
Table of Contents
v
Table of Contents
6.11. SET COUNT ........................................ 209 4.2. Setting the Database Page Fill Ra-
6.12. SET ECHO ........................................... 210 tio ................................................................ 239
6.13. SET LIST ............................................... 211 4.3. Sizing Database Cache Buffers ........... 239
6.14. SET NAMES ........................................ 212 4.4. Buffering Database Writes .................. 240
6.15. SET PLAN ........................................... 212 5. Database Design Principles .................... 241
6.16. SET STATS ........................................... 213 5.1. Defining Indexes .................................. 241
6.17. SET TIME ............................................. 214 5.2. Normalizing Databases ...................... 242
6.18. SHELL .................................................. 215 5.3. Choosing Blob Segment Size ............. 242
6.19. SHOW CHECK .................................... 216 6. Database Tuning Tasks ............................ 242
6.20. SHOW DATABASE .............................. 216 6.1. Tuning Indexes .................................... 243
6.21. SHOW DOMAINS .............................. 217 6.2. Performing Regular Backups .............. 244
6.22. SHOW EXCEPTIONS .......................... 217 6.3. Facilitating Garbage Collection .......... 245
6.23. SHOW FILTERS .................................. 218 7. Application Design Techniques ............. 245
6.24. SHOW FUNCTIONS ........................... 218 7.1. Using Transaction Isolation Modes ..... 245
6.25. SHOW GENERATORS ........................ 219 7.2. Using Correlated Subqueries .............. 246
6.26. SHOW GRANT ................................... 219 7.3. Preparing Parameterized Queries ...... 246
6.27. SHOW INDEX .................................... 220 7.4. Designing Query Optimization
6.28. SHOW PROCEDURES ........................ 221 Plans ............................................................ 247
6.29. SHOW ROLES ................................... 222 7.5. Deferring Index Updates .................... 248
6.30. SHOW SUBSCRIPTION ..................... 222 8. Application Development Tools ............. 248
6.31. SHOW SYSTEM .................................. 223
6.32. SHOW TABLES .................................. 224 MIGRATING TO INTERBASE ...................... 251
6.33. SHOW TRIGGERS .............................. 224
1. Migration Process .................................... 251
6.34. SHOW VERSION ............................... 225
2. Migration Issues ....................................... 252
6.35. SHOW VIEWS ................................... 225
2.1. InterBase SQL Dialects ........................ 252
7. Using SQL Scripts .................................... 226
2.2. Clients and Databases ........................ 252
7.1. Creating an isql Script ......................... 226
2.3. Keywords Used as Identifiers .............. 252
7.2. Running a SQL Script .......................... 227
2.4. Understanding SQL Dialects ............... 253
7.3. Committing Work in a SQL Script ...... 227
3. Setting SQL Dialects ................................ 254
7.4. Adding Comments in an isql Script .... 228
3.1. Setting the isql Client Dialect .............. 254
DATABASE AND SERVER PERFOR- 3.2. Setting the gpre Dialect ...................... 255
MANCE ......................................................... 231 3.3. Setting the Database Dialect .............. 255
3.4. Features and Dialects ......................... 255
1. Introduction to Database and Server Per- 4. Migrating Servers and Databases .......... 271
formance ....................................................... 231 4.1. In-place Server Migration .................... 271
2. Hardware Configuration ......................... 231 4.2. Migrating to a New Server ................. 272
2.1. Choosing a Processor Speed .............. 231 4.3. About InterBase 6 and Later, Dialect 1
2.2. Sizing Memory .................................... 232 Databases ................................................... 273
2.3. Using High-performance I/O Subsys- 4.4. Migrating Databases to Dialect 3 ....... 274
tems ............................................................ 232 4.5. Migrating Clients ................................. 280
2.4. Distributing I/O ................................... 232 4.6. Migrating Data from Other DBMS
2.5. Using High-bandwidth Network Sys- Products ...................................................... 281
tems ............................................................ 234
2.6. Using high-performance Bus ............. 234 INTERBASE LIMITS ..................................... 282
3. Performance Considerations for a Net-
work Configuration ...................................... 237 1. Various InterBase Limits .......................... 282
3.1. Choosing a Network Protocol ............. 237
3.2. Configuring Hostname Lookups ........ 237
4. Database Properties ................................ 238
4.1. Choosing a Database Page Size ......... 238
vi
Operations Guide
Operations Guide
The Operations Guide covers the "how-to" information on working with InterBase databases. Topics in-
clude:
• Using IBConsole
• Configuring and operating the InterBase server
• Network configuration
• Performing backups and restores
• Using journaling and journal archiving
• Database security
• Interactive queries
Embarcadero Technologies 1
Introduction to Operations
Introduction to Operations
The InterBase Operations Guide is a task-oriented reference of procedures to install, configure, and main-
tain an InterBase database server or Local InterBase workstation.
This chapter describes who should read this book, and provides a brief overview of the capabilities and
tools available in the InterBase product line.
The InterBase server software makes efficient use of system resources on the server node. The server
process uses little more than 1.9MB of memory. Typically, each client connection to the server adds ap-
proximately 115KB of memory. This varies based on the nature of the client applications and the database
design, so the figure is only a baseline for comparison.
Embarcadero Technologies 2
Introduction to Operations
The minimal software installation requires disk space ranging from 9MB to 12MB, depending on platform.
During operation, InterBase sorting routine requires additional disk space as scratch space. The amount
of space depends on the volume and type of data the server is requested to sort.
The InterBase client also runs on any of these operating systems. In addition, InterBase provides the Inter-
Client Java client interface using the JDBC standard for database connectivity. Client applications written
in Java can run on any client platform that supports Java, even if InterBase does not explicitly list it among
its supported platforms. Examples include the Macintosh and Internet appliances with embedded Java
capabilities.
• Terminology: Windows server platforms Throughout this document set, there are references to
“Windows server platforms” and “Windows non-server platforms.” The Windows server platforms are
Windows Server 2008, Windows 2008 R2 (64-bit), Windows Server 2012, Windows Server 2012 R2,
and Windows Server 2016. Windows non-server platforms are, Windows Vista, Windows 7, Windows
8, Windows 8.1, and Windows 10.
Feature Description
Network protocol support All platforms of InterBase support TCP/IP
Embarcadero Technologies 3
Introduction to Operations
Feature Description
Outer joins Relational construct between two tables that enables com-
plex operations.
Explicit transaction Full control of transaction start, commit, and rollback, in-
management cluding named transactions.
Concurrent multiple application access to data. One client reading a table does not block others from it.
multidimensional arrays Column data types arranged in an indexed list of elements.
Automatic two-phase commit Multi-database transactions check that changes to all
databases happen before committing (InterBase Server on-
ly).
InterBase API Functions that enable applications to construct SQL/DSQL
statements directly to the InterBase engine and receive re-
sults back.
gpre Preprocessor for converting embedded SQL/DSQL state-
ments and variables into a format that can be read by a
host-language compiler; included with the InterBase server
license.
IBConsole Windows tool for data definition, query, database backup,
restoration, maintenance, and security.
isql Command-line version of the InterBase interactive SQL tool;
can be used instead of IBConsole for interactive queries.
Command-line database administrator utilities Command-line version of the InterBase database adminis-
tration tools; can be used instead of IBConsole.
Header files Files included at the beginning of application programs
that define InterBase data types and function calls.
Example make files Files that demonstrate how to invoke the makefiles to com-
pile and link InterBase applications.
Example programs C programs, ready to compile and link, which you can use
to query standard InterBase example databases on the
server.
Message file interbase.msg, containing messages presented to the us-
er.
4.1. SQL Support
InterBase conforms to entry-level SQL-92 requirements. It supports declarative referential integrity with
cascading operations, updatable views, and outer joins. InterBase Server provides libraries that support
development of embedded SQL and DSQL client applications. On all InterBase platforms, client applica-
tions can be written to the InterBase API, a library of functions with which to send requests for database
operations to the server.
InterBase also supports extended SQL features, some of which anticipate SQL99 extensions to the SQL
standard. These include stored procedures, triggers, SQL roles, and segmented Blob support.
Embarcadero Technologies 4
Introduction to Operations
You can write user-defined functions (UDFs) and store them in an InterBase database, where they are
accessible to all client applications accessing the database.
4.3. Transaction Management
Client applications can start multiple simultaneous transactions. InterBase provides full and explicit trans-
action control for starting, committing, and rolling back transactions. The statements and functions that
control starting a transaction also control transaction behavior.
InterBase transactions can be isolated from changes made by other concurrent transactions. For the life of
these transactions, the database appears to be unchanged except for the changes made by the transaction.
Records deleted by another transaction exist, newly stored records do not appear to exist, and updated
records remain in the original state.
4.4. Multigenerational Architecture
InterBase provides expedient handling of time-critical transactions through support of data concurrency
and consistency in mixed use – query and update – environments. InterBase uses a multigenerational
architecture, which creates and stores multiple versions of each data record. By creating a new version of
a record, InterBase allows all clients to read a version of any record at any time, even if another user is
changing that record. InterBase also uses transactions to isolate groups of database changes from other
changes.
InterBase implements true row-level locks, to restrict changes only to the records of the database that a
client changes; this is distinct from page-level locks, which restrict any arbitrary data that is stored physically
nearby in the database. Row-level locks permit multiple clients to update data that is in the same table
without coming into conflict. This results in greater throughput and less serialization of database operations.
InterBase also provides options for pessimistic table-level locking. See the Embedded SQL Guide for details.
4.6. Database Administration
InterBase provides both GUI and command-line tools for managing databases and servers. You can per-
form database administration on databases residing on Local InterBase or InterBase Server with IBConsole,
a Windows application running on a client PC. You can also use command-line database administration
utilities on the server.
Embarcadero Technologies 5
Introduction to Operations
You can find more information on server security later in this chapter, and later chapters describe individual
tasks you can accomplish with IBConsole and the command-line tools.
NOTE
Starting with version XE7 InterBase implements stronger password protection on InterBase databases. See Implementing
Stronger Password Protection.
You can add and delete user names and modify a user’s parameters, such as password and user ID.
For information about managing server security, see Database User Management
For information about database backup and recovery, see About InterBase backup and restore options.
4.6.3. Maintaining a Database
You can prepare a database for shutdown and perform database maintenance using either IBConsole or
the command-line utilities. If a database incurs minor problems, such as an operating system write error,
these tools enable you to sweep a database without taking the database off-line.
• Sweeping a database
• Shutting down the database to provide exclusive access to it
• Validating table fragments
• Preparing a corrupt database for backup
• Resolving transactions “in limbo” from a two-phase commit
• Validating and repairing the database structure
Embarcadero Technologies 6
Introduction to Operations
For information about database maintenance, see Database Configuration and Maintenance
4.6.4. Viewing Statistics
You can monitor the status of a database by viewing statistics from the database header page, and an
analysis of tables and indexes. For more information, see Database Statistics and Connection Monitoring
The UNIX versions of InterBase include all of the following command-line tools. The graphical Windows
tools do not run on a UNIX workstation, though you can run most of the tools on Windows to connect to
and operate on InterBase databases that reside on UNIX servers.
An advantage of noninteractive, command-line tools is that you can use them in batch files or scripts to
perform common database operations. You can automate execution of scripts through the scheduling
facility of your operating system(cron on UNIX, AT on Windows). It is more difficult to automate execution
of graphical tools.
isql
The isql tool is a shell-type interactive program that enables you to quickly and easily enter SQL statements
to execute with respect to a database. This tool uses InterBase Dynamic SQL mechanism to submit a state-
ment to the server, prepare it, execute it, and retrieve any data from statements with output (for example,
from a SELECT or EXECUTE PROCEDURE). isql manages transactions, displays metadata information, and
can produce and execute scripts containing SQL statements.
See Interactive Query for full documentation and reference on isql and using isql from IBConsole.
gbak
The gbak tool provides options for backing up and restoring databases. gbak now backs up to multiple files
and restores from multiple files, making it unnecessary to use the older gsplit command. Only SYSDBA
and the owner of a database can back up a database. Any InterBase user defined on the server can restore
a database, although the user must be SYSDBA or the database owner in order to restore it over an
existing database.
NOTE
When you back up and restore databases from IBConsole on Windows platforms, you are accessing this same tool
through the IBConsole interface.
See About InterBase backup and restore options for full documentation and reference on using gbak.
gfix
Embarcadero Technologies 7
Introduction to Operations
You can also access all the functionality of gfix through the IBConsole graphical interface. Only SYSDBA
and the owner of a database can run gfix against that database.
See Database Configuration and Maintenance for descriptions of these properties, and a reference of the
gfix tool.
gsec
You can configure authorized users to access InterBase servers and databases with gsec. You can also
perform the same manipulations on the security database with IBConsole.
gstat
gstat displays some database statistics related to transaction inventory, data distribution within a database,
and index efficiency. You can also view these statistics from IBConsole. You must be SYSDBA or the owner
of a database to view its statistics.
See Database Statistics and Connection Monitoring for more information on retrieving and interpreting
database statistics.
iblockpr (gds_lock_print)
Note that the gds_lock_print utility is deprecated and is not included with some versions of
InterBase.
You can view statistics from the InterBase server lock manager to monitor lock request throughput and
identify the cause of deadlocks in the rare case that there is a problem with the InterBase lock manager.
The utility is called gds_lock_print on the UNIX platforms, and iblockpr on the Windows platforms.
See Database Statistics and Connection Monitoring for more information on retrieving and interpreting
lock statistics.
ibmgr
On UNIX servers, use the ibmgr utility to start and stop the InterBase server process. See the section Using
ibmgr to Start and Stop the Server for details on using this utility.
Embarcadero Technologies 8
Licensing
Licensing
This chapter summarizes the licensing provisions and add-ons available for InterBase products. The licens-
ing information in this chapter is not meant to replace or supplant the information in the much more
detailed license agreement you receive at the time of purchase. Instead, this chapter summarizes general
licensing terms and options.
To activate and use an InterBase product, you must register it when you install it or soon after. For detailed
instructions on how to install InterBase products, see the IBsetup.html file that you receive upon purchase.
This chapter also provides basic instructions on how to use the InterBase License Manager to view
existing license information for the products you have purchased, to register those products if you have
not already, and to view additional add-ons licenses.
To view available InterBase add-ons and licenses, you can use the InterBase License Manager, which installs
with your product. For more information, see Using the License Manager.
NOTE
To distribute the InterBase software to third parties as bundled with your own software application or installed on your
hardware, you must contact Embarcadero Technologies and enter into an Original Equipment Manager (OEM) license
agreement.
1.1. Server Edition
InterBase Server Edition software provides strong, symmetric multiple processing support, and robust
database and server monitoring facilities.
NOTE
You can use the same serial number to install and register Server Edition software on a second computer for backup
purposes as long as the second computer is not used concurrently with the primary installation.
Embarcadero Technologies 9
Licensing
1.2. Developer Edition
The Developer Edition License is limited to use of the Server Edition for development purposes only, using
solely client applications executing on the same, single computer as the server. This license grants no rights
for use in a production environment.
1.3. Desktop Edition
The InterBase Desktop Edition is an InterBase database server designed to run in a stand-alone environ-
ment for use by a single end user. You can deploy the Desktop Edition on a desktop, laptop, or other
mobile computer.
• Install a single copy of the Desktop Edition on a single computer for your internal data processing
needs only
• Log into the same computer on which the software is running and make up to eight (8) connections
to the InterBase Desktop Edition software.
1.4. ToGo Edition
The InterBase ToGo Edition is a small, portable version of the Desktop Edition, and is designed to run in a
stand-alone environment. Refer to System Requirements/Prerequisites for a list of supported platforms.
The ToGo Edition does not contain all of the options, such as IBConsole, that are available in the Desktop
Edition. For information on how to use the ToGo edition, see the InterBase Developer's Guide.
Embarcadero Technologies 10
Licensing
• Deploy applications that are embedded with the InterBase ToGo engine (DLL's).
• Deploy ToGo Edition software on a standalone computer for use by a single end user.
A separate License Manager tool installs with the Desktop, ToGo, and Server Editions. to view existing
license information for the products you have purchased, to register those products if you have not already,
and to view additional licenses for add-ons.
If your Linux or Solaris environment does not support the GUI installer, you can use the command-line tool
to register additional options and licenses. For information on how to do so, see the IBsetup.html file.
IMPORTANT
In versions of InterBase prior to 2007, you could access an older version of the License Manager from IBConsole. Because
the IBConsole version of License Manager does not contain up-to-date licensing information and options, including
add-ons, we recommend that you use only the separate InterBase License Manager tool to purchase new licenses. For
more information on licenses refer to Installation, Registration, and Licensing Information.
1. From the Start menu, select Programs > Embarcadero InterBase 2017 > License Manager.
The License Manager window opens.
2. To view and select the add-ons available for the InterBase product you are using, click on the Serial
menu and select Add.
3. When the Add Serial Number dialog opens, type in your serial number and click OK. The License
Manager displays licensing information and allows you to register the product you purchased if you
have not done so already.
Embarcadero Technologies 11
Licensing
1. From the Start menu, select Programs > Embarcadero InterBase 2017 > License Manager. The
License Manager window opens.
2. To view and select the add-ons available for the InterBase product you are using, click on the Serial
menu and select Add.
3. When the Add Serial Number dialog opens, type in your serial number and click OK. The License
Manager displays licensing information and allows you to register the product you purchased if you
have not done so already.
Embarcadero Technologies 12
Server Configuration
Server Configuration
This chapter describes the operation and configuration of the InterBase server process, including the fol-
lowing topics:
• Select a server (or any branch under the server hierarchy) in the Tree pane and choose Server|Server
Properties.
• Select a server in the Tree pane and click Server Properties in the Work pane.
• Right-click a server in the Tree pane and choose Server Properties from the context menu.
The Server Properties dialog contains two tabs, Alias and General.
The General tab of the Server Properties dialog is where you can view such server settings as the version,
capabilities, number of databases, and number of attachments. You cannot edit the information displayed
on this tab.
Embarcadero Technologies 13
Server Configuration
• Number of databases: displays the total number of databases in the InterBase Server.
• Number of attachments: displays the total number attachments to the InterBase Server.
You cannot update the information displayed on the General tab; however, you can click Refresh at any
time to retrieve the current server property information. If you need to view or configure server settings,
click the IB Settings tab.
On the Alias tab, you can inspect the host name and network protocol for the server. You can inspect and
change the Alias name and description.
• Alias Name: the name of the server as it appears in the Tree pane. This setting is editable.
• Host Name: the name of the host server. This is determined at the time you create the server con-
nection and cannot be changed in this dialog.
• Network Protocol: the protocol that the server is using to communicate. This is determined at the
time you create the server connection and cannot be changed in this dialog.
• Description: any additional information you wish to add about the server. This field is optional and
editable.
2. Multi-Instance
InterBase 2007 (equivalent to version 8.0) and above allow multiple instances of InterBase servers to run
simultaneously. In versions previous to 7.5, multiple instances of the InterBase server could not be run
on the same machine. In these earlier versions, when an application utilized one version of InterBase,
another application that utilized another version of InterBase could not be run. With InterBase 7.5, and
later versions, you can run one previous version (major release) of InterBase, i.e. InterBase 6.x while you
are running a newer version simultaneously.
Embarcadero Technologies 14
Server Configuration
The service_name is the entry contained in the services file pointing to the port number which the InterBase
server should bind to. Below is an example of a part of the file from the <system directory>\drivers\etc
\services file.
The InterBase environment variable or the -i switch is used for local connections. These values determines
which InterBase server a client on the same machine will connect to. The InterBase environment variable
for a client and server's -i switch must match to have a successful connection. So if InterBase server is
started with the setting:
The InterBase server will accept remote connections on the TCP/IP port number 3051 as the service ib__a
is set to port 3051. The local connections will be accepted from client on the same machine who have their
InterBase environment variable set to C:\Program Files\interbase.
Older versions of InterBase servers (pre-7.5) can still run using the default setting. These pre-7.5 InterBase
servers will accept remote connections on TCP/IP port number 3050. The local connections will be accepted
when the client uses a pre-7.5 interbase client library.
We recommend using the -i switch to set the local InterBase variable for the server. The order in which
InterBase server looks for the InterBase environment variable is as follow; Command line argument '-i',
InterBase environment variable setting, InterBase Registry key setting, Server's current directory.
In order to connect to a specific InterBase server on a machine you need to identify the server you want
to connect to.
Remote Servers
In order to access the database database_name.ib located in the directory database_dir. On a remote ma-
chine remote_host accepting connections on a port number specified by a service_name on the client ma-
chine. The database name specified in isql, the client API or any InterBase driver should be remote_host/ser-
vice_name:/database_dir/database_name.ib
Assume that a remote client application wants to access windows server running on a machine called
remote_host running 2 servers with the example configuration specified above. The client machine will
need to have the same service name set as the server, so the services file will need to have these entries:
Embarcadero Technologies 15
Server Configuration
In order to access an InterBase server running on the 3051 port number, use the following database
connection string (through isql or through the API) remote_host/3051:c:\database_dir\ib80test.ib.
For older clients specify the service name which is bound to the port number on which the older server is
listening e.g. remote_host/gds_db:c:\database_dir\ib71test.ib
In order to access a database on a local InterBase server, InterBase depends on the InterBase Environment
variable to identify the server to be connected to. A pre-7.5 InterBase server running will be connected to
if no server with the InterBase environment variable setting is running.
In order to access an older server make sure that your application uses the older gds32.dll. To access a
older server using a 7.5 InterBase client library make sure your InterBase environment variable is set to
a empty string "".
Applications can also pass in the information regarding the InterBase server they want to attach to as part
of the InterBase database parameter block (isc_dpb parameter). Setting the isc_dpb_client_interbase_var
followed by the length and the location of the InterBase server will allow the user to specify the InterBase
server to be used. The following code demonstrates how a client should set the dpb parameter to attach
to a InterBase server running with the InterBase environment variable set to "c:/interbase"
#include <ibase.h>
…
char dpb_buffer[256], dpb;
short dpb_length;
char *ib_server = "c:/interbase";
char *str = "employee.ib";
isc_db_handle db1;
ISC_STATUS status_vector[20];
/* construct the dpb, specifing the IB server to attach to */
dpb = dpb_buffer;
*dpb++ = isc_dbp_version;
*dpb++ = isc_dpb_client_interbase_var;
*dpb++ = strlen(ib_server);
strcpy (dpb, ib_server);
/* set other dpb parameters */
…
/* set the dpb_length as usual */
dpb_length = dpb - dpb_buffer;
/* finally call isc_attach or create with the dpb parameters */
isc_attach_database(status_vector, strlen(str), str, &db1, dpb_length,
dpb_buffer);
Embarcadero Technologies 16
Server Configuration
e.g. Server_Name:DATABASE_DIR\EMPLOYEE.Ib
SERVICE_NAME CHAR 30 Service name to look up in the services file for the port number
to be re-routed to. The look up takes place at the server side, the
client is only aware of the port number and not the service name.
e.g. ib__a
ACTIVATE_ROUTE BOOLEAN Set to true if this re-routing is active, flase it this re-routing is dis-
abled.
The service name that is entered in the set DB_ROUTE table must exist in the services file:
In order to setup the database server AGNI so that it can re-route in coming connections, for the database
c:\smistry\employee.ib to an older server running on port number specified by the service ib__a. The
ADMIN.IB database on server AGNI will need the following row of information in DB_ROUTE table.
Embarcadero Technologies 17
Server Configuration
Since the DB_ROUTE is a regular InterBase table in the ADMIN.IB database, you can use regular SQL to
enter, modify or remove database re-routing from information.
2.5. Startup Parameters
To accommodate multiple instances of InterBase running on the same machine the InterBase Guardian
and Server now have label names as part of their Service names.
The InterBase Server and Guardian have two new command line arguments:
Command line arguments are called start parameters as far as starting the applications are concerned.
If you write to the Microsoft auto run registry key entry you will need to do the same to the
3. SMP Support
InterBase provides symmetric multiprocessor (SMP) support for both clients and servers. Older versions of
InterBase ran on SMP systems safely by allowing only a single processor at a time to execute within the
InterBase components. Current versions of InterBase exploit SMP hardware by running InterBase threads
on all processors simultaneously for increased throughput and performance.
IMPORTANT
When you purchase a single server license, you acquire the right to use a single processor. You must purchase one
additional license for each additional processor that you wish to use.
On Windows platforms, the CPU_AFFINITY setting in the ibconfig configuration file specifies which pro-
cessors of a multiprocessor system InterBase should use. The default setting, in effect when CPU_AFFINITY
is commented out, is to use as many processors as licensing permits. See Expanded Processor Control:
CPU AFFINITY below for how to specify a subset of processors to use.
Embarcadero Technologies 18
Server Configuration
IMPORTANT
Note that when you purchase a single server license, you acquire the right to use a single processor. You must purchase
one additional license for each additional processor that you wish to use.
The CPU_AFFINITY parameter populates a bit vector in which each bit represents a processor on the system
on which the threads are allowed to run. The maximum number of processors depends on the operating
system. To specify which processors should be used, give CPU_AFFINITY a decimal value that corresponds
to the binary value that results from setting a bit for each desired machine. For example, to use processors
2 and 3, set CPU_AFFINITY to 6:
CPU_AFFINITY 6
Setting the MAX_THREADS parameter in ibconfig controls the maximum number of threads that can be
active at one time within the InterBase engine. The default setting is 100:
MAX_THREADS 100
This configuration parameter controls the number of active threads in the engine. The ideal setting for this
number depends partly on the nature of the work being performed by your clients. If you have many clients
performing very similar tasks, you may want to lower the MAX_THREADS setting to reduce contention.
On the other hand, if simultaneous activity is highly diverse, setting this to a higher value may increase
throughput.
Note that this setting does not affect the maximum possible threads that can be created by the InterBase
server but only the number that can be active in the engine at one time.
This parameter controls the stack size of various threads in InterBase. The value is in multiple of MBs per
thread. The valid range is 2MB to 32MB. If it is set beyond the range, the value defaults to 2MB.
You should not have to change this parameter for normal use of InterBase. In extremely rare cases of
abnormal termination of the process, the reason might be thread stack space constraints due to high levels
of recursive calls (of stored procedures and such). Feel free to increase this value then.
Embarcadero Technologies 19
Server Configuration
• Choose the server startup mode: whether to start the InterBase server manually, or have it start au-
tomatically at system boot time.
• Change the path to the server: if you click the Change option, you can browse and select a different
directory.
• Change how InterBase Server operates. By default, InterBase runs automatically as a service on Win-
dows platforms, though it is possible (but not recommended) to run it as an application.
NOTE
To start InterBase Server as an application from a command prompt or in a batch file, invoke InterBase Guardian with
the following options:
Command/option Description
-a Start as application.
-i Environment variable; identifies the Server location for
clients that want to connect locally to the Server.
-p Port number; where the <service_name> is the entry in the
services file pointing to the port number where InterBase
Server listens for connection requests from clients.
InterBase Guardian starts the server, and places an icon in the System Tray.
• Start InterBase Server and InterBase Guardian, via a Start/Stop button. Click Start in the InterBase
Manager Status area to start InterBase Server (and InterBase Guardian). The server status changes, and
an InterBase Guardian icon appears in the system tray. Once you have started the InterBase Server,
Embarcadero Technologies 20
Server Configuration
you can exit InterBase Manager, and both InterBase Server and InterBase Guardian will continue to
run. The InterBase Guardian icon remains in the System Tray until you stop the server.
• Stop InterBase Server and InterBase Guardian, via a Start/Stop button. Click Stop in the InterBase
Manager Status area to stop InterBase Server (and InterBase Guardian). Or, right-click the InterBase
Guardian icon in the System Tray and choose Shutdown.
The InterBase Server and InterBase Guardian must be started before you enable database connections.
On Windows platforms, you can use the InterBase Manager to start and stop the InterBase Server and
Guardian. In previous versions of InterBase, the InterBase Manager is a Windows Control Panel applet.
Now the InterBase Manager is an application installed for each instance of the InterBase Server installed.
To start the InterBase Manager, choose Start > Programs > InterBase install directory. You can use
InterBase Manager to do the following:
• Choose the server startup mode: whether to start the InterBase server manually, or have it start au-
tomatically at system boot time.
• Change the path to the server: if you click the Change option, you can browse and select a different
directory.
• Change how InterBase Server operates. By default, InterBase runs automatically as a service on Win-
dows platforms, though it is possible (but not recommended) to run it as an application.
NOTE
To start InterBase Server as an application from a command prompt or in a batch file, invoke InterBase Guardian with
the following options:
Com- Description
mand/op-
tion
-a Start as application
-i Environment variable; identifies the Server location for clients that want to connect locally to the Server.
-p Port number; where the <service_name> is the entry in the services file pointing to the port number
where InterBase Server listens for connection requests from clients.
InterBase Guardian starts the server and places an icon in the System Tray.
• Start InterBase Server and InterBase Guardian, via a Start/Stop button. Click Start in the InterBase
Manager Status area to start InterBase Server (and InterBase Guardian). The server status changes, and
an InterBase Guardian icon appears in the system tray. Once you have started the InterBase Server,
you can exit InterBase Manager, and both InterBase Server and InterBase Guardian will continue to
run. The InterBase Guardian icon remains in the System Tray until you stop the server.
Embarcadero Technologies 21
Server Configuration
• Stop InterBase Server and InterBase Guardian, via a Start/Stop button. Click Stop in the InterBase
Manager Status area to stop InterBase Server (and InterBase Guardian). Alternatively, right-click the
InterBase Guardian icon in the System Tray and choose Shutdown.
To start the InterBase server, log in as the “root” or “interbase” user. (“interbase” is a synonym for “InterBase,”
to accommodate operating systems that do not support nine-character account names.) For example,
start InterBase with the following command:
NOTE
Once you have started ibserver using one login, such as “root,” be aware that all objects created belong to that login.
They are not accessible to you if you later start ibserver as one of the other two (“interbas” or “InterBase”). It is highly
recommended to run the InterBase Server as “InterBase.” If the -p option is not specified, the default of gds_db is used.
NOTE
For safety, make sure all databases have been disconnected before you stop the server.
The command switches -user and -password can be used as option switches for commands like -start or
-shut. For example, you can shut down a server in any of the following ways:
or
ibmgr u
IBMGR> shut -password password
or
imbgr u
IBMGR> password password
IBMGR> shut
NOTE
The -shut option rolls back all current transactions and shuts down the server immediately. If you need to allow clients
a grace period to complete work and detach gracefully, use shutdown methods for individual databases. See Shutting
Down and Restarting Databases.
To configure a UNIX server to start the InterBase Server automatically at server host boot-time, you must
install a script that the rc initialization scripts can run. Refer to /etc/init.d/README for more details on how
UNIX runs scripts at boot-time.
Embarcadero Technologies 22
Server Configuration
#!/bin/sh
# ibserver.sh script - Start/stop the InterBase daemon
# Set these environment variables if and only if they are not set.
: ${InterBase:=/usr/interbase}
# WARNING: in a real-world installation, you should not put the
# SYSDBA password in a publicly-readable file. To protect it:
# chmod 700 ibserver.sh; chown root ibserver.sh
export InterBase
ibserver_start() {
# This example assumes the InterBase server is
# being started as UNIX user ’InterBase’.
echo ‘$InterBase/bin/ibmgr -start -forever’ |su InterBase
}
ibserver_stop() {
# No need to su.
$InterBase/bin/ibmgr -shut -user SYSDBA -password password
}
case $1 in
’start’) ibserver_start ;;
’start_msg’) echo 'InterBase Server starting...\c' ;;
’stop’) ibserver_stop ;;
’stop_msg’) echo 'InterBase Server stopping...\c' ;;
1. Log in as root.
$ su
2. Enter the example script above into the initialization script directory.
# vi /etc/init.d/ibserver.sh
3. Enter text.
4. Link the initialization script into the rc directories for the appropriate run levels for starting and stop-
ping the InterBase server.
# ln /etc/init.d/ibserver.sh /etc/rc0.d/K30ibserver
# ln /etc/init.d/ibserver.sh /etc/rc2.d/S85ibserver
Embarcadero Technologies 23
Server Configuration
1. Log in as root.
$ su
2. Enter the Linux example script (given below) into the initialization script directory.
# cp ibserver.sh /etc/rc.d/init.d/ibserver.sh
# chmod 700 /etc/rc.d/init.d/ibserver.sh
3. Link the initialization script into the rc directories for the appropriate run levels for starting the Inter-
Base server.
# ln -s /etc/rc.d/init.d/ibserver.sh /etc/rc.d/rc0.d/S85ibserver
4. Link the initialization script into the rc directories for the appropriate run levels for stopping the In-
terBase server.
# ln -s /etc/rc.d/init.d/ibserver.sh /etc/rc.d/rc0.d/K30ibserver
# touch /etc/gds_hosts.equiv
# echo “+” >> /etc/gds_hosts.equiv
6. Make sure you do not have an inetd entry for InterBase Classic.
#!/bin/sh
# ibserver.sh script - Start/stop the InterBase daemon
# Set these environment variables if and only if they are not set.
: ${InterBase:=/usr/interbase}
# WARNING: in a real-world installation, you should not put the
# SYSDBA password in a publicly-readable file. To protect it:
# chmod 700 ibserver.sh; chown root ibserver.sh
export InterBase
ibserver_start() {
# This example assumes the InterBase server is
# being started as user “InterBase”.
su - InterBase -c “$InterBase/bin/ibmgr -start -forever”
RETVAL=$?
[ $RETVAL -eq 0 ] && touch //lock/subsys/ibserver
}
ibserver_stop() {
# No need to su.
Embarcadero Technologies 24
Server Configuration
if [ ! -d “$InterBase” ] ; then
echo “$0: cannot find InterBase installed at $InterBase” >&2
exit 1
fi
if [ ! -x “$InterBase/bin/ibmgr” ] ; then
echo “$0: cannot find the InterBase SuperServer manager as
$InterBase/bin/ibmgr” >&2
if [ ! -x “$InterBase/bin/gds_inet_server” ] ; then
echo “$0: this is InterBase Classic; use inetd instead of
ibserver daemon” >&2
fi
exit1
fi
case $1 in
’start’)
ibserver_start ;
echo “InterBase started” ;;
’start_msg’)
echo 'InterBase Server starting...\c' ;;
’stop’)
ibserver_stop ;
’restart’)
ibserver_stop ; ibserver_start
echo “InterBase restarted” ;;
’restart_msg’)
echo 'InterBase Server restarting...\c' ;;
All successful attempts to create or connect to a database increment the number of current attachments.
Both local and remote connections count toward the connection limit. Connections are permitted by the
governor until the maximum number of concurrent attachments is reached. All successful attempts to drop
or disconnect from a database decrement the number of current attachments.
Embarcadero Technologies 25
Server Configuration
Once the maximum number of attachments is reached, the server returns the error constant isc_max_at-
t_exceeded (defined in ibase.h), which corresponds to the message:
Although setting these environment variables is convenient, do not do so if security is at all an issue.
The INTERBASE variable is used both during installation and during runtime. During installation, it defines
the path where the InterBase product is installed. If this path is different from /usr/interbase, all users must
have the correct path set at runtime. During runtime, use the INTERBASE variable to set the InterBase install
directory. The INTERBASE environment variable is used on Windows for local connections. The INTERBASE
environment variable is used by the client to identify the local instance of InterBase Server to attach to.
INTERBASE_TMP
The INTERBASE_TMP variable can be used to set the location of InterBase sort files on the server. There
are other options for defining the location of these files. See Configuring Sort Files.
INTERBASE_LOCK sets the location of the InterBase lock file and INTERBASE_MSG sets the location of the
InterBase message file. These two variables are independent of each other and can be set to different
locations.
IB_PROTOCOL
Embarcadero Technologies 26
Server Configuration
The IB_PROTOCOL is used to specify which port you want the InterBase Server to use during runtime.
It is also used by the InterBase Manager to identify which InterBase Server to manage. It is used by the
InterBase clients to identify the instance of InterBase server to connect to.
127.0.0.1 localhost
If your local machine has additional names, include them in the line:
The InterBase server creates sort files when the size of the internal sort buffer is not big enough to perform
the sort. Each request (for example, CONNECT or CREATE DATABASE) gets and shares the same list of
temporary file directories. Each request creates its own temporary files (each has its own I/O file handle).
Sort files are released when sort is finished or the request is released. If space runs out in a particular
directory, InterBase creates a new temporary file in the next directory from the directory list. If there are
no more entries in the directory list, it prints an error message and stops processing the current request.
The InterBase isql client creates the history list files to keep track of the input commands. Each instance
creates its own temporary files, which can increase in size until they run out of disk space. Temporary file
management is not synchronized between clients. When a client quits, it releases its temporary files.
To set the location for history files, define the TMP environment variable on your client machine. This is the
only way to define the location of history files. If you do not set the location for the history files by defining
the TMP environment variable, an InterBase client uses whatever temporary directory it finds defined for
the local system. If no temporary directory is defined, it uses /tmp on a UNIX system or C:\temp on a
Windows system.
You should make sure to have plenty of free space available for temporary sorting operations. The maxi-
mum amount of temporary space InterBase needs might be larger than the database itself in some cases.
Embarcadero Technologies 27
Server Configuration
Temporary sort files are always located on the server where the database is hosted; you should specify
temporary directories on disk drives that are physically local to the server (not on mapped drives or network
mounted file systems).
• You can add an entry to the $InterBase/ibconfig file to enable directory and space definition for sort
files. The syntax is:
IMPORTANT
The pathname must be in double quotes, or the config file will fail.
This defines the maximum size in bytes of each sort directory. You can list several directories, each on
its own line with its own size specification and can specify a directory more than once with different size
configurations. InterBase exhausts the space in each specification before proceeding to the next one.
For example, if you specify dir1 with a size of 5,000,000 bytes, then specify dir2 with 10,000,000 bytes,
followed by dir1 with 2,000,000 bytes, InterBase uses dir1 until it reaches the 5,000,000 limit, then uses
dir2 until it has filled the 10,000,000 bytes allocated there, and then returns to dir1 where it has another
2,000,000 bytes available.
• You can use the INTERBASE_TMP and TMP environment variables to define the location.
If you specify temporary directories in ibconfig, the server uses those values for the sort files and ignores
the server environment variable values. If you do not specify configuration of temporary directories in
ibconfig, then the server picks a location for a sort file based on the following algorithm:
• <parameter> is a string that contains no white space and names a property of the server being
configured.
• <value> is a number or string that is the configuration of the specified property.
Embarcadero Technologies 28
Server Configuration
Each line in ibconfig is limited to 80 characters, including the parameter name and any whitespace.
If you specify a value of zero or less for a parameter, the server ignores the setting and uses the default
value for that parameter. However, there is no upper limit applied to these parameters.
The server reports the values for each of these parameters in the interbase.log file on startup.
When a parameter is commented out in the ibconfig file, the server uses the default value.
Contents of ibconfig
Parameter Description
ADMIN_DB
• Platforms: All
• Specifies the name of the InterBase security database.
• Needed only if the security database is not named.
admin.ib
• Platforms: All
• Seconds to wait before concluding an attempt to connect has failed.
• Default: 180
DATABASE_CACHE_PAGES
• Platforms: All
Embarcadero Technologies 29
Server Configuration
Contents of ibconfig
Parameter Description
• Platforms: All
• Version: starting in InterBase XE7
• The database server/engine will automatically create/restore databases to
this major ODS version number, if specified.
• Valid ODS major versions are in the range of 13 to 16.
• Default major ODS version is the latest version supported by the product.
• Default: 16
DEADLOCK_TIMEOUT
• Platforms: All
• Seconds before an ungranted lock causes a scan to check for deadlocks.
• Default: 10
DUMMY_PACKET_INTERVAL
• Platforms: All
• Seconds to wait on a silent client connection before the server sends dummy
packets to request acknowledgment.
• The default value of 0 will not send any dummy keepalive packets to the
client from the server.
• Versions of InterBase before 7.1 used to have this set at 60 seconds, by de-
fault. This has now been modified to have a default of 0 (zero) seconds due
to a memory leak bug in one of the Windows system drivers for socket con-
nections.
• Alternatively, you can set the interval value for a specific client by using the
isc_dpb_dummy_packet_interval DPB parameter while doing a connection.
ENABLE_HYPERTHREADING
• Platforms: Windows, for InterBase 32-bit Edition(s) only
• Specifies whether Intel Hyper-threading technology enabled logical proces-
sors should be enabled.
• Valid values are: 1 (enable), 0 (disable).
• Default: 0 (disable)
ENABLE_PARTIAL_INDEX_SELECTIV-
ITY • Platforms: All
• Starting with InterBase XE7 and ODS 16, multi-segment index definitions
track per segment selectivity statistics.
• Specifies whether the SQL Optimizer should use this selectivity data to opti-
mize retrieval.
• This setting is engine-wide, so it applies to all queries submitted to an active
engine.
• When disabled, the SQL optimizer will treat the index with a single selectivity
value that is not segment specific, as per InterBase versions prior.
Embarcadero Technologies 30
Server Configuration
Contents of ibconfig
Parameter Description
EXTERNAL_FILE_DIRECTORY "C:\Temp"
EXTERNAL_FILE_DIRECTORY "/tmpdir"
• List multiple entries one per line; directories are used in the order specified.
EXTERNAL_FUNCTION_DIRECTORY
• Platforms: All
• The default directory for UDF libraries is <interbase_home>/UDF.
• Using this parameter, you can list additional directories where UDF libraries
should be loaded from.
• For security reasons, do not put other files in this directory.
• Directory path MUST be enclosed in double quotes. For e.g.
EXTERNAL_FUNCTION_DIRECTORY "C:\Temp"
EXTERNAL_FUNCTION_DIRECTORY "/tmpdir"
• List multiple entries one per line; directories are used in the order specified.
LOCK_ACQUIRE_SPINS
• Platforms: All
• Number of spins during a busy wait on the lock table mutex
• Relevant only on SMP machines
• Default: 0
LOCK_HASH_SLOTS
• Platforms: All
• Tune lock hash list; more hash slots means shorter hash chains.
• Not necessary except under very high load
• Prime number values are recommended.
• Default: 101
MAX_DB_VIRMEM_USE
• Platforms: Windows
• Define an upper percentage limit of how much of the available virtual mem-
ory InterBase can use for its large memory allocations like those of database
Embarcadero Technologies 31
Server Configuration
Contents of ibconfig
Parameter Description
cache etc. This is set as a percentage of total virtual memory available to the
process.
• This can be used to set the limit to a lower level if you observe that oth-
er critical memory allocations such as file I/O buffers, file handles, socket
buffers etc. need the user space.
• Valid range that can be set is between 50 and 100.
• Please note that setting this to 100 indicates that InterBase can use up all
available virtual memory for its database cache etc. This is not recommend-
ed. For e.g.
setting this to 90 (the default), indicates that on a 2GB virtual address space,
InterBase process will only use up 1.8GB of the available virtual memory for
database cache allocations; the rest will be available for other critical memory al-
locations.
MAX_THREADS
• Platforms: All
• Controls the maximum number of threads that can be active at one time
within the InterBase engine. The listed value applies to a system with mul-
tiple licensed CPUs. For a single CPU system, the value defaults to 1 which
eliminates the synchronization overhead required by multiple CPUs.
• Default: 1000000
MAX_ASSISTANTS
• Platforms: All
• Controls the maximum number of threads that can be active assisting oth-
er threads with their tasks. This number should be less than the number of
CPUs on which InterBase can run.
• Default: 1
MEMORY_RECLAMATION
• Platforms: All
• Number of seconds between attempts to return unused memory to OS.
• This parameter enables better co-existence with neighboring processes by
not monopolizing memory. It cannot guarantee that other processes will be-
have in kind.
• 0 = disable memory reclamation
• 1 = memory reclamation on attach of first database
• 2 = memory reclamation on detach of last database
• 3 = 1 + 2 above
• > 15 = number of seconds between memory reclamations
• Default: 300
PAGE_CACHE_EXPANSION
• Platforms: All
• Number of MB of memory to expand page buffer cache until upper lim-
it is reached. The upper limit can be a database-specific setting or the
DATABASE_CACHE_PAGES parameter. The page buffer cache is expanded
when there are no more free buffers, which occurs when all buffers have
been loaded with a database page.
• This parameter is used to smooth the memory allocation of page buffers to
match demand generated by client load.
• 0 = allocate all page buffers on first database attach.
Embarcadero Technologies 32
Server Configuration
Contents of ibconfig
Parameter Description
• > 0 = expand this many MBs at a time until all page buffers allocated.
• Default: 256
PREDICTIVE_IO_PAGES
• Platforms: All
• Starting with InterBase XE7, InterBase introduced predictive I/O mechanism
to populate in-memory database cache with interesting pages that can be
fetched instead of read from disk by request worker threads.
• This setting allows you to manipulate the number of pages to be prefetched
in one shot, between the values 0 and 64.
• As a special case, a setting of 0 pages will disable the predictive I/O mecha-
nism
• Valid values include:
Default: 64
Disable feature: 0
• This parameter should be left on its default status and changed only for test-
ing purposes when it is suspected to produce performance issues.
Embarcadero Technologies 33
Server Configuration
Contents of ibconfig
Parameter Description
• Default: 0
SOLARIS_SYNC_SCOPE
• Platform: Solaris
• When set to 1 threads use process-level synchronization variables.
• The default of 0 causes thread-level synchronization variables to be used.
• Default: 0
SORTMEM_BUFFER_SIZE
• Platforms: All
• Specifies the size of a sort buffer in memory.
• Versions of InterBase before 7.1 used to have a static value of approx. 128
KB. This is now configurable per server using this parameter. The default val-
ue is just about 1 MB.
• Setting this to a higher value will enable better performance in large sort-
merge queries.
• Default: 1048500
SQL_COMPILER_RECURSION
• Platforms: All
• Specifies the call depth that the recursive descent parsing algorithm will try
during SQL compilation phase of statement preparation. If the call depth
would exceed this limit than a stack overflow is declared and returned as an
error. Note that this is an artificial stack overflow detection and not a hard-
ware detected stack overflow.
• Default: 2000
STARTING_TRANSACTION_ID
• Platforms: All
• Version: starting in InterBase XE7
• ODS version: 16+
• The database server/engine will automatically create/restore databases with
this transaction ID as the starting number.
• If you want to restore your database(s) to test with very high transaction ID
numbers, to evaluate 48-bit transaction ID support, set this value and restart
InterBase.
• Valid values include any value >= 0, that can be represented in a 48-bit Inte-
ger data type.
• Default starting transaction ID on database create/restore is 0
• Default: 0
SWEEP_QUANTUM
• Platform: All
• Specifies the maximum number of records that a garbage collector thread
or a sweeper thread is allowed to work before yielding control back to the
worker threads.
• Default:10
SWEEP_YIELD_TIME
• Platforms: All
• Specifies the time, in milliseconds, the sweeper or garbage collector thread
sleeps.
• Default:1 millisecond
Embarcadero Technologies 34
Server Configuration
Contents of ibconfig
Parameter Description
TCP_REMOTE_BUFFER
• Platforms: All
• TCP/IP buffer size for send and receive buffers. This applies to both client
and server programs.
• Valid range is 1448 to 32768
• Default: 8192 bytes
TMP_DIRECTORY
• Platforms: All
• Directory to use for storing temporary files (such as sort files).
• Default is the value of environment variables INTERBASE_TMP or TMP, in that
order; otherwise /tmp on UNIX or C:\temp on Windows NT/2000/XP.
• If you have lots of space in your default temporary folders as above, then
there is no need to mention any further directory listings here.
• Specify directory path and number of bytes available in the directory.
• Directory path MUST be enclosed in double quotes.
• Format for entry is as follows.
• For e.g.
• List multiple entries, one per line; directories are used in the order specified.
USER_QUANTUM
• Platforms: All
• Specifies the maximum number of records that a worker thread (thread run-
ning an user query) is allowed to work before yielding control back to other
threads.
• Default: 1000
V4_EVENT_MEMSIZE
• Platforms: ALL
• Bytes OF shared memory allocated FOR event manager.
• Default: 32768
V4_LOCK_GRANT_ORDER
• Platforms: All
• 1 means locks are granted first come, first served.
• 0 means emulate InterBase V3.3 behavior, where locks are granted as soon
as they are available; can result in lock request starvation.
• Default: 1
V4_LOCK_MEM_SIZE
• Platforms: ALL
• Bytes OF shared memory allocated FOR LOCK manager.
Embarcadero Technologies 35
Server Configuration
Contents of ibconfig
Parameter Description
Refer to the Language Reference for a list of error messages that can appear in this file.
IBConsole displays this log file in a standard text display window. To display the Server Log dialog:
• Select a server and expand it if it is not already expanded, click Server Log and then double-click View
Logfile in the Work pane.
• Right-click a server in the Tree pane and choose View Logfile from the context menu.
• Select a server and then choose View Logfile from the Server menu.
Embarcadero Technologies 36
Server Configuration
The standard text display window enables you to search for specific text, save the text to a file, and print
the text. For an explanation of how to use the standard text display window, see Text Viewer Window.
Embarcadero Technologies 37
Network Configuration
Network Configuration
This chapter details issues with configuring InterBase in a networked client/server environment. Topics
include network protocols supported by InterBase, remote connection specifiers, encrypting the data that
passes between servers, and network troubleshooting tips.
1. Network Protocols
InterBase supports TCP/IP for all combinations of client and server platforms. Additionally, InterBase sup-
ports NetBEUI on Windows server platforms and for all Windows clients, and a local connection mode
(involving inter-process communication but no network interface) for Windows clients.
InterBase is designed to allow clients running one operating system to access an InterBase server that is
running on a different platform and operating system than the client.
In the following table, Windows non-server platforms are Windows 7 (32-bit and 64-bit), Windows Vista
(32-bit and 64-bit), Windows XP Pro (32-bit). Windows servers are Windows 2008 and Windows 2008 R2
(64-bit).
2.1. Adding a Server
You can access the Add Server Wizard in IBConsole by one of the following methods:
• Choose Server|Add or click the Add a New InterBase Server toolbar button.
• Double-click InterBase Servers in the Tree pane.
• Right-click InterBase Servers and choose Add from the context menu.
When you add a server, and there is no local server yet added, the Local Server dialogue opens.
If a local server already exists, the Remote Server Setup dialog opens.
Embarcadero Technologies 38
Network Configuration
1. Once you have clicked Server|Add, click Next in the Welcome dialog to advance to the Local Server
Setup panel.
Embarcadero Technologies 39
Network Configuration
4. You can choose to just add the server (without logging in) or you can choose to add and connect
to the server simultaneously.
• If you want to just add the server you can ignore the Login Information and click Next.
• If you want to add and connect to the server simultaneously, enter a username and password in the
corresponding text fields and click Next.
NOTE
The usernames and passwords must be the InterBase usernames and passwords stored in the InterBase security
database (admin.ib by default) on the server.
5. Click Next to advance to the Finish Wizard. Here you have the option to enter a description name
for the server.
6. Click Finish and once a server is added, IBConsole displays it in the Tree pane.
Embarcadero Technologies 40
Network Configuration
1. Choose Server > Add or click the Add a New InterBase Server toolbar button and the Remote Server
Setup dialog appears.
7. You can choose to just add the server (without logging in) or you can choose to add and connect
to the server simultaneously.
• If you want to just add the server you can ignore the Login Information and click Next.
Embarcadero Technologies 41
Network Configuration
• If you want to add and connect to the server simultaneously, enter a username and password in the
corresponding text fields and click Next.
NOTE
The usernames and passwords must be the InterBase usernames and passwords stored in the InterBase security
database (admin.ib by default) on the server.
8. Click Next to the Finish Wizard dialog. Here you have the option to enter a description name for
the server.
9. Click Finish and once a server is added, IBConsole displays it in the Tree pane.
2.2. Logging in to a Server
You can access the Server Login dialog in IBConsole by one of the following methods:
• In the Tree pane, select a registered server that is not already logged in. Choose Server|Login, or
double-click Login in the Work pane.
• In the Tree pane, double-click a registered server that is not already logged in.
• In the Tree pane, right-click a registered server that is not already logged in and choose Login from
the context menu.
To log in to a server:
Embarcadero Technologies 42
Network Configuration
The usernames and passwords must be the InterBase usernames and passwords that are stored in the
InterBase security database (admin.ib by default) on the server.
The username is significant to 31 bytes and is not case-sensitive. The password is significant to eight char-
acters and is case-sensitive.
All users must enter their username and password to log in to a server. The username and password are
verified against records in the security database. If a matching record is found, the login succeeds.
IMPORTANT
Initially, every server has only one authorized user with username SYSDBA. The SYSDBA must log on and add other
authorized users. For more information about how to add new users, see User Administration with IBConsole.
You can log out from a server in IBConsole by one of the following methods:
• Select a connected server in the Tree pane (you can also select any branch under the desired server
hierarchy) and choose Server|Logout.
• Select a connected server in the Tree pane and double-click Logout in the Work pane.
• Right-click a connected server in the Tree pane and choose Logout from the context menu.
A confirmation dialog asks you to confirm that you wish to close the connection to the selected server.
Click Yes if you want to log out from the server, otherwise click No.
2.4. Removing a Server
To remove a server in IBConsole by one of the following methods:
A confirmation dialog asks you to confirm that you wish to remove the selected server. Click Yes if you
want to remove the server, otherwise click No.
NOTE
Removing a server removes that server from the Tree pane and automatically logs you out of the current server as well
as disconnects any databases on the server.
Embarcadero Technologies 43
Network Configuration
2.5. Adding a Database
You can access the Add Database and Connect dialog in IBConsole by one of the following methods:
• Choose Database|Add.
• Expand a connected server branch. Right-click Databases in the Tree pane and choose Add from the
context menu.
• Select a disconnected database in the Tree pane and double-click Add in the work pane, or right-click
the database and choose Add from the context menu.
To Add a Database:
If you only want to add the database, ignore the Login Information and click OK.
9. If you want to add and connect a database simultaneously, type the username, password and optional
role and default character set for the database in the corresponding text fields and click OK.
Embarcadero Technologies 44
Network Configuration
If you want to connect using a role, specify the role in the Role text field. This is optional. Connecting using
a role gives you all privileges that have been assigned to that role, assuming that you have previously been
granted that role with the GRANT statement. For more information on roles, refer to SQL Roles.
• Select a disconnected database in the Tree pane. Choose Database|Connect, choose Connect in the
Work pane, or click on the Database Connect toolbar button.
• Right-click a disconnected database in the Tree pane and choose Connect from the context menu.
• Double-click a disconnected database in the Tree pane.
Once you connect to a database, the database tree expands to display the database hierarchy.
• Select a disconnected database in the Tree pane. Choose Database|Connect As or choose Connect
As in the Work pane.
• Right-click a disconnected database in the Tree pane and choose Connect As from the context menu.
This displays the Database Connect dialog box:
Embarcadero Technologies 45
Network Configuration
4. Select the SQL Client dialect. The dialect for the database connection will default to the lower value
of the client or server. For more information on SQL dialects, refer to “Understanding SQL Dialects”
in the migration appendix of the InterBase Operations Guide.
5. Optionally, you can choose a character set to use. If you do not specify one here, the server uses the
default set that was specified at creation time.
6. Click Connect.
Once you connect to a database, the database tree expands to display the database hierarchy.
2.7. Disconnecting a Database
You can disconnect a database in IBConsole by one of the following methods:
• Select a connected database in the Tree Pane (you can also select any branch under the desired
database hierarchy) and choose Database|Disconnect or click the Disconnect Database toolbar
button
• Select a connected database in the Tree pane and double-click Disconnect in the Work pane.
• Right-click a connected database in the Tree pane and choose Disconnect from the context menu.
Embarcadero Technologies 46
Network Configuration
A confirmation dialog asks you to confirm that you wish to close the connection to the selected database.
Click OK if you want to disconnect the database, otherwise click Cancel.
2.8. Un-registering a Database
Un-registering a database automatically disconnects the current database and removes it from the Tree
pane.
You can un-register a disconnected database in IBConsole by one of the following methods:
• Select a database in the Tree pane (you can also select any branch under the desired database hier-
archy) and choose Database|Un-register.
• Select a database in the Tree pane and double-click Un-register in the Work pane.
• Right-click a database in the Tree pane and choose Un-register from the context menu.
A confirmation dialog asks you to confirm that you wish to un-register the database. Click Yes if you want
to un-register the database, otherwise click No.
2.9. Connection-specific Examples
Here are some examples of connecting to databases on various types of servers.
• For a Windows server, the database path name must contain the appropriate drive letter designation.
For example, to connect to a local database:
D:\users\accting\fin\accred.ib
ntserver:D:\users\accting\fin\accred.ib
• To connect via NetBEUI (Windows server platforms only), use UNC notation:
\\ntserver\D:\users\accting\fin\accred.ib
• For a UNIX or Linux server, you must enter the complete and absolute directory path for the database.
For example:
server:/usr/accting/fin/accred.ib
Embarcadero Technologies 47
Network Configuration
In the XE3 release, a Strong Encryption license was incorporated into the server license that allows AES
encryption which applies to OTW. This is no longer an add-on license, but is automatically part of Serv-
er/Desktop.ToGo Edition.
You can also use InterBase to encrypt a database and/or individual columns in a database table. For
information on how to do so, see the Data Definition Guide.
NOTE
The OTW functionality is designed to be used in conjunction with the InterBase database user name and password. It
is not meant to replace it.
InterBase uses the following conventions on both the client and server sides:
• All the X.509 PKI (public key infrastructure) files, which include the certificate file and the CA files, must
be in the Privacy Enhanced Mail (PEM) format.
• The clientCertFile and IBSSL_SERVER_CERTFILE parameters always refer to the PEM formatted file that
contains the CA signed certificate and the private key. These files should not be distributed.
• The serverPublicPath and serverPublicFile parameters on the client, and IBSSL_SERVER_CAFILE and
IBSSL_SERVER_CAPTH on the server, always refer to the public key certificate.
• InterBase supports both stronger (AES) and weak (DES) encryptions out of the box. InterBase XE and
earlier supports the use of weak encryption (DES) out of the box, but to use stronger encryption (AES),
you must, due to U.S. export regulations, obtain a strong encryption license from InterBase and install
it on the server machine.
NOTE
NOTE
For information on specifying JDBC properties for OTW, see SSL File Properties. Also in the Developer's Guide, table
4.10 defines the new extended properties.
Before setting up OTW encryption on the server or client side, you must first obtain the necessary
security certificates, provided by your Certificate Authority (CA) vendor. InterBase uses these certificates
to verify identity information.
Embarcadero Technologies 48
Network Configuration
You can use any SSL tool to generate these certificates, or contact your IT department or CA vendor. To
learn how to create SSL certificates using OpenSSL, see the following website:
• https://www.openssl.org/docs/manmaster/man1/openssl.html
NOTE
The existing OTW properties have been changed to the new JDBC OTW properties.
IMPORTANT
It is strongly recommended that the old native OTW properties no longer be used. However, the new native client and
server supports both the old and new names.
It is likely that this will be the last release of InterBase Client which supports the old parameters. It is
important that you start using the new parameters:
Syntax: To enable OTW on the client side, use the following syntax for your database connection string:
<secure server host name>[/secure server port name | secure server port
number]?ssl=true[?serverPublicFile=complete location of the CA file
| ?serverPublicPath=name
of directory containing the CA certificates |?clientCertFile=name of the
client certificate file][?clientPassPhraseFile=pass phrase filename
|?clientPassPhrase=pass phrase]??:<database path>/<database name>
The starting '?ssl=true' and the ending '??' are mandatory, and work as demarcations for the OTW encryp-
tion parameters. The following table lists the descriptions of the options used in the syntax sample.
Embarcadero Technologies 49
Network Configuration
Note: This option replaces the “OTWENABLE” option. It is strongly recommended that the
OTWENABLE option no longer be used.
serverPublicFile Location of the certificate file. By default, InterBase searches for ibserverCAfile.pem in the us-
er’s home directory. Both the serverPublicFile and serverPublicPath (defined below) must fol-
low the PEM format as per standard SSL requirements. The client will not be expected to cre-
ate this file. This file will be created by the database administrator of the server you are con-
necting to. If you are the person generating this file, please ensure that the public certificate
file has been created binding the certificate to the DNS of the server. This DNS must match
the <secure host name> used by the client.
Note: This option replaces the “CAFILE” option. It is strongly recommended that the CAFILE
option no longer be used.
serverPublicPath If you use and mention the serverPublicPath, then each file in the directory must contain on-
ly a single CA certificate and the files must be named by the hash of the subject name and
extension of “.0”. There are no default for this option. It is recommended that you use the
serverPublicFile as opposed to serverPublicPath; if you specify both, serverPublicFile will be
used. The organization hosting the server will provide the CA file. This file is used to verify
that the connection is being made to a legitimate and verified server. Care must be taken
to ensure that you are referencing the CA you want to use. Please see About the “c_rehash”
command for more information.
Note: This option replaces the “CAPATH” option. It is strongly recommended that the CAP-
ATH option no longer be used.
In addition, if you need to enable server verification of the client, you can use the parameters
described in the table below. An example follows the table:
Note: This option replaces the “CERTFILE” option. It is strongly recommended that the CERT-
FILE option no longer be used.
clientPassPhraseFile Name and location of the text file containing the client private key passphrase. You can use
either the clientPassPhrase File parameter, or the clientPassPhrase parameter.
Note: This option replaces the “PASSPHRASEFILE” option. It is strongly recommended that
the PASSPHRASEFILE option no longer be used.
clientPassPhrase Specify a private key PassPhrase. You can use either the clientPassPhrase parameter or the
clientPassPhraseFile parameter.
Embarcadero Technologies 50
Network Configuration
Note: This option replaces the “PASSPHRASEFILE” option. It is strongly recommended that
the PASSPHRASEFILE option no longer be used.
Use this command if you want to use the serverPublicPath parameter instead of the serverPublicFile on
the client or the IBSSL_SERVER_CAPATH instead of the IBSSL_SERVER_CAFILE parameter on the server.
For more information on how to set up this directory please go to the OpenSSL website and look for the
c_rehash command.
“c_rehash” is a command provided by OpenSSL. This script automatically creates symbolic links to a di-
rectory of certificates. For example, suppose that you have a directory called some/where/certs, which
contains several CA certificates, and that you want to prepare this directory for use as a serverPublicPath
directory. In this case, you can use the following commands:
cd /some/where/certs
c_rehash .
In addition, the InterBase server requires two DH (Diffie-Hellman) parameter files to operate. For more
information about the dhparameter files, see Generating the dhparameter files.
IBSSL_SERVER_HOST_NAME=localhost
IBSSL_SERVER_PORT_NO=3065
IBSSL_SERVER_PHASSPHRASE=serverkey
IBSSL_SERVER_clientCertFile=<install_directory>/secure/server/ibserver.pem
#IBSSL_SERVER_PASSPHRASEFILE=c:/secure/pass.txt
#example comment line
#only needed for client verification
#IBSSL_SERVER_VERIFY_CLIENT
#IBSSL_SERVER_CAFILE=<install_directory>/secure/server/root.pem
The following table provides a description of each parameter in the sample above.
Embarcadero Technologies 51
Network Configuration
Parameter Description
IBSSL_SERVER_PORT_NO and IBSS- Port number and the hostname of the SSL port number and SSL machine name
L_SERVER_HOST_NAME (can be localhost) of the InterBase server the InterBase Server is running on. The
defaults are machine name or host name and '3065.' In most cases, the IBSS-
L_SERVER_HOST_NAME need not be set.
IBSSL_SERVER_CERTFILE Location of the private key stored in a file.This will be used by the server for encryp-
tion. (Default location and filename: will the <install_directory>/secure/server/ib-
server.pem. The IBSSL_SERVER_CERTFILE must be in PEM format and must contain
both the private key and the certificate.
IBSSL_SERVER_PASSPHRASEFILE Location of the file containing the passphrase. This must be secure. Make sure you
have the correct permissions for this file; the server only needs read access to the
file during start up time. The log file will indicate via a message that the passphrase
is not loaded. This means you can have the pass phrase on a removable media and
once the server has started the media (and hence the passphrase) maybe safely re-
moved.
IBSSL_SERVER_PASSPHRASE Contains the server pass phrase to be used in conjunction with the server certifi-
cate file. Use this instead of the IBSSL_SERVER_PASSPHRASEFILE. If both are set the
IBSSL_SERVER_PASSPHRASE is used instead of IBSSL_SERVER_PASSPHRASEFILE. If
both are not set, InterBase assumes that the private key does not contain a pass
phrase.
IBSSL_SERVER_VERIFY_CLIENT If this parameter is set, then the server will ensure that the client has sent us a cer-
tificate. This certificate will be verified against the file specified in the IBSSL_SERV-
ER_CAFILE (or the directory specified in the IBSSL_SERVER_CAPTH).
IBSSL_SERVER_CAFILE Location of the file containing the CA file, which can be used to verify the client cer-
tificate.There is no default for this file. However, it is recommended that you locate
the file in <install_directory>/secure/server/ and call it ibrootcert.pem. The file must
be in PEM format and is needed only if the IBSSL_SERVER_VERIFY_CLIENT flag is set.
IBSSL_SERVER_CAPATH Used for the same purpose as the IBSSL_SERVER_CAFILE. However, in this case, the
parameter points to a directory containing the CA certificates in PEM format. The
files each contain one CA certificate and are only needed if the IBSSL_SERVER_VER-
IFY_CLIENT flag is set. The files are looked up by the CA subject name hash val-
ue, which must be available. See “About the “c_rehash” command” for information
about this command, which can be used to convert multiple PEM files into a IBSS-
L_SERVER_CAPATH-accessible directory.
Embarcadero Technologies 52
Network Configuration
You are encouraged to generate your own DH parameter files, if you want these files to be unique to
your installation. Otherwise, the default ones provided by InterBase will be used. In order for the InterBase
server to make successful SSL connections, these files are required.
To set up the sample server for OTW, take the following steps:
1. Copy the ibserverCAfile.pem provided by the server DBA to the user’s home directory.
2. Using isql, make a connection using the following as your URL. Assume your server and client are on
the same machine then the hostname is “localhost”.
Embarcadero Technologies 53
Network Configuration
You are now set up to use OTW. This example used default locations for all the certificate and CA files
used. If you do not use the defaults and decide to change the location of the server files, you must change
the IBSSL_SERVER_CERTFILE parameter in the ibss_config file to point to your PEM formatted Certificate
(plus private key) file.
If you locate the CA file (on the client machine) in a directory other than your home directory use the
following command on connect:
1. Copy the ibrootcert.pem file to the <install_directory>/secure/server directory. This is the public key
certificate used by the server to identify the client.
2. The ibss_config file must be modified to indicate to the server that client verification has been enabled,
and that the public key certificate location. This is done by adding the following to the <install_direc-
tory>/secure/server/ibss_config file:
IBSSL_SERVER_VERIFY_CLIENT
IBSSL_SERVER_CAFILE=c:\InterBase\secure\server\ibrootcert.pem
1. Copy the ibclient.pem file, which is a PEM formatted file that contains the client certificate and private
key, to your HOME directory on the client. Assume that your HOME directory is C:\smistry, then the
complete path for the file will be c:\smistry\ibclient.pem.
2. Specify the location of your client certificate and private key on the connection URL. For example, if
you are connecting to c:/foo.ib using isql, the command would be:
isql> connect
“localhost/3065?ssl=true?clientCertFile=C:\smistry\ibclient.pem??:c:/foo.ib”;
Embarcadero Technologies 54
Network Configuration
You can use the "keytool -genkey" to generate a new self signed private key and public key pair. This
password is to be used when making a connection via JDBC (clientPassPhrase).
These commands created a new keystore called smclient.jks. It contains your private and public key and
a self signed certificate.
If you follow this example then the following values need to be appended to your JDBC connection URL
to make a JDBC connection using client side verification.
?clientPrivateFile=c:/smistry/smclient.jks?clientPassPhrase=client
Next you can use the keytool -export -rfc to export you public key. This public key must be added to the
server, and pointed to by the server using the IBSSL_SERVER_CAFILE option in the ibss_config file.
-----BEGIN CERTIFICATE-----
MIIDHzCCAtwCBEpt7k4wCwYHKoZIzjgEAwUAMHUxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEW
MBQGA1UEBxMNU2NvdHRzIFZhbGxleTEUMBIGA1UEChMLRW1iYXJjYWRlcm8xEjAQBgNVBAsTCUlu
dGVyQmFzZTEXMBUGA1UEAxMOU2hhdW5hayBNaXN0cnkwHhcNMDkwNzI3MTgxMzM0WhcNMDkxM-
Embarcadero Technologies 55
Network Configuration
DI1 .....
utRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6
ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAOOavhpQAOLHr/Yw59LrA
SOflcsA15BaAy1NUEl65cqb1/TO/jWroKjlG8dv1uNdsc2kZ4ptmM0L2RjksLxcrqUBm9qjedan9
X8cjEnTeU2hOrmARoZeFhlvtw4CfiuXwnFeagF2IxrETyVLEXMV1A5ATRzrdTqQcfnw-
PCua0F3Ew-----END CERTIFICATE-----
CwYHKoZIzjgEAwUAAzAAMC0CFQCJtK/qpIw0ahuIYqYP5d1D90UbdAIUEeU4nXvZAUxZv5SPcFFP
uowm7bI= -----END CERTIFICATE-----
Now the file mycert.pem contains your public certificate. Move this to the server and make sure this is
included in the file pointed to by the IBSSL_SERVER_CAFILE.
If you want to get your private key validated by a certification authority, the client need to use the "keytool
-certreq" command to generate a certificate signing request for a Certificate signing authority. Once this
request is validated you would add this certificate reply to your keystore via a "keytool -import" command.
This is followed by a "keytool -export" command to get the certificate to authenticate your public key. This
exported certificate will then be moved to the InterBase server, so the InterBase server can "trust" and
verify the client private key.
4. Connection Troubleshooting
This section describes some troubleshooting guidelines for issues related to network configuration and
client/server connections. If you are having trouble connecting client to server over a network, use the
steps listed below to diagnose the cause. On Windows, you can perform some of these tests using the
Communications Diagnostic dialog. See Communication Diagnostics for more information.
Embarcadero Technologies 56
Network Configuration
You can quickly test whether the client cannot reach the server because of a physically disconnected net-
work or improper network software configuration, by using the ping command. Usage is:
ping servername
Error messages from ping indicate that there is a network problem. Check that the network is plugged in,
that the network wires are not damaged, and that the client and server software is properly configured.
Test connectivity from the client in question to another server; if it succeeds, this could rule out improper
network configuration on the client.
Test connectivity from another client to the InterBase server host; if it succeeds, this could rule out improper
network configuration on the server.
InterBase clients must specify the server by name, not by IP address, except in some Linux distributions.
Therefore, the client must be able to resolve the server’s hostname. For TCP/IP, this is done either by
maintaining a hosts file on the client with the mappings of hostnames to IP addresses, or by the client
querying a DNS server or WINS server to resolve this mapping. Make sure the name server has a correct
entry for the server host in question.
If the database server is behind a software or hardware firewall, all network traffic could be restricted and
the client might not be able to reach the server at all. Some firewalls permit or restrict traffic based on the
port to which the client attempts to connect. Because of this, it is not conclusive whether a given service
can reach the server. Neither is it an indication of connectivity if the client can resolve the IP address; that
merely indicates that the client can reach a name server that resolves the InterBase server hostname.
If the client is separated from the server by a firewall, the client cannot connect.
NetBEUI cannot route network traffic between subnets. Other protocols can also be configured to restrict
traffic between subnets. If the client and server are on a complex network with multiple subnets, ask your
network administrator if the network configuration allows you to route network traffic between the client
and server in question using a given protocol.
To confirm that the ibserver process is running on the server and able to attach to your database, try a
local database connection:
1. Log in to the console of the database server host, and run an application such as command-line isql.
2. Attempt to connect to a database without specifying a hostname: list just the path.
The Communications Diagnostic dialog also has a local database attachment test. See DB Connection Tab
for details.
Embarcadero Technologies 57
Network Configuration
NOTE
You can simulate a client/server connection and test the configuration of the server without the additional
variable of the client configuration and intervening network by connecting in a loopback mode.
1. Log in to the console of the database server host and run an application such as command-line isql
or InterBase IBConsole isql.
2. Attempt to connect to the database using a remote connection specification, even though the server
named is also the client host.
Whether this test fails or succeeds, it helps to narrow the focus of further diagnostic tests. If it fails, you
can infer that the configuration of the server is at fault. If it succeeds, you can infer that the server is not
at fault and you can concentrate further tests on the client.
If the process on the server has not started, there is no answer to attempts to connect to the
ibserver
gds_db service (port 3050).
Start the ibserver process on the server. Use ibmgr -start on UNIX, or the InterBase Manager on Windows.
See Server Configuration
The services file must have correct entries to indicate the port number associated with the named service
gds_db. This configuration must be accessible on the client as well as the server.
In a UNIX environment with NIS, the NIS server can be configured to supply the services file to all NIS
clients on UNIX workstations.
Embarcadero Technologies 58
Network Configuration
Verify that you supplied the correct path to the database file. Keep in mind:
• On Windows, you must supply the drive letter with the path.
• On UNIX, paths are case-sensitive.
• Slash (“/”) vs. backslash (“\”) does not matter, unless you need to use double-backslashes in string
literals in C or C++ code.
To use the UNIX user-equivalence feature, there must be a trusted host relationship between the client
and the server. See Users on UNIX.
A database file must not reside on an NFS file system or a mapped drive. When the ibserver process finds
such a case, it either denies the connection or passes the connection request on to the InterBase service
running on the file server. See Networked File Systems for more details.
To correct this situation, move your database to a file system on a hard disk that is physically local to the
database server.
The client application must use a valid user and password combination that matches an entry in the Inter-
Base security database (admin.ib by default).
The ibserver process must have permission to read and write the database file at the operating system
level. Check the permissions on the database file, and the uid of the ibserver process. (On UNIX, you have
the option of running ibserver as user InterBase, a non-superuser uid.)
The InterBase security database (admin.ib by default) that contains users and passwords must also be
writable by the ibserver process.
Does the server have permissions to create files in the InterBase install directory?
The ibserver process must have write permission in the InterBase directory (by default, /usr/InterBase on
UNIX, C:\Program Files\Embarcadero\InterBase on Windows). The server process must be able to write
to, and perhaps create, the interbase.log file and other temporary files.
Embarcadero Technologies 59
Network Configuration
modem dialing program. This is helpful for users who want to connect quickly as they launch a web browser
or email client application.
This convenience feature is unnecessary on systems that use a client/server application to access an Inter-
Base server on a local network. The TCP/IP service request that the client invokes triggers the Windows
automatic modem dialer. This interferes with quick network connections from client to server.
This section describes several methods to suppress the automatic modem dial feature of Windows oper-
ating systems. No more than one of these methods should be necessary to accomplish the networking
configuration you need.
The local ethernet adapter satisfies TCP/IP requests it can, and those requests that can't be done locally—
such as Internet requests—are passed on to the next adapter in the list, the dialup adapter.
A better way to view these is to type rasautou-s from the command prompt
3. In the sub-keys, look for the local address and name; select the key and select Delete from the Edit
menu
4. Close the registry editor
Embarcadero Technologies 60
Network Configuration
4.4. Other Errors
Unknown Win32 error 10061
This error is often associated with a missing server-access license for the InterBase software on the server
host. Make sure you have licensed InterBase server to allow clients to connect from the network.
This error occurs in cases when the InterBase client cannot establish a network connection to the server
host. This can occur for a variety of reasons. Below is a list of common causes:
• The BDE Administrator requires that you specify the InterBase connect string in the SERVER NAME alias
property. You must use this property and must not use the PATH alias property, or else you receive
the network error message.
• The InterBase client attempts to translate the server portion of your connect string to an IP address,
by calling gethostbyname(). If you supplied an IP address, gethostbyname() is likely to fail to resolve
it. Some modern TCP/IP drivers – including Winsock 2 and Linux TCP/IP – do resolve strings that look
like IP addresses. If you are on Windows, specify hosts by name, or else upgrade your TCP/IP driver
to Winsock 2.
• The InterBase client must look up the InterBase network service by name. If the client doesn’t find the
entry for gds_db in the services file, it might fail to connect to the server, and give the network error.
You can create the entry in the services file manually, or reinstall InterBase to perform this task.
• The server you specify must be running on the network that you use. If the hostname corresponds
to a host that is inaccessible because of network interruption, or the host is not running, then the
connection request fails with the network error.
• The syntax of the InterBase connect string determines the network protocol the client uses to connect
to the server host (see Connection-specific Examples). Different server platforms support different
subsets of network protocols. If your server does not support the protocol indicated by your connect
string, the connection attempt fails with the network error. For example, the NetBEUI connection syntax
(\\server\C:\path\database.ib) works only if your server is a windows 2008, or XP server. The syntax
does not work if your server is running UNIX or Linux.
• A network connection request succeeds only if the InterBase server is installed and active on the server
host, and that the InterBase server is licensed to receive remote connection requests. If there is no
process listening for connection requests, the client’s connection requests with the network error. You
should check that the InterBase server is installed on the server, that it is running, and that the license
includes the Server capability.
5. Communication Diagnostics
Network configuration of a client/server system involves several different software and hardware layers
and proper configuration of each of these layers. When one or more layers are mis-configured, it is not
always evident where the problem lies. InterBase Communication diagnostics helps to identify the source
of the problem by testing each layer progressively for existing or potential network problems.
You can access the Communication Diagnostics dialog by one of the following methods:
Embarcadero Technologies 61
Network Configuration
• Right-click InterBase Servers or any disconnected server in the Tree pane and choose Diagnose Con-
nection from the context menu.
• Select a disconnected server from the Tree pane and double-click Diagnose Connection in the Work
pane.
There are four types of diagnostics that you can perform. The Communications Diagnostics dialog has
separate tabs for each diagnostic type.
The InterBase server name is the name of the database server machine. There is not a specific name for
the InterBase server process itself. For example, if the server is running on the NT server “venus”, you enter
this name in the Server Name text field.
4. If you choose Remote Server, select a network protocol from the drop-down list: either TCP/IP, Net-
BEUI, named pipe, or local. Protocols are valid only when they are supported by both the client and
the server.
Embarcadero Technologies 62
Network Configuration
5. Enter the database filename, including the path where file is located, in the Database text field. If you
selected the Local Server option in step 1 you can also click the browse button to locate the file you
want. If you selected the Remote Server option, however the browse button is disabled.
6. Type the username and password for the database in the corresponding User Name and Password
text fields.
7. Click Test to display the results of the connectivity test in the Results text area.
C:\Program Files\Embarcadero\InterBase\examples\Database\employee.ib
Attaching ...Passed!
Detaching ...Passed!
InterBase Communication Test Passed!
5.2. TCP/IP Tab
Use this property sheet to test Winsock TCP/IP connectivity.
1. Enter either a network host name or IP address in the Host text field.
2. Select a service name or number from the drop-down Service list. Possible service selections are: 21,
Ping, 3050, ftp, gds_db.
Select Ping from the Service drop-down list to display a summary of round-trip times and packet loss
statistics.
1. Click Test to display the results of the connectivity test in the Results text area.
Embarcadero Technologies 63
Network Configuration
Initialized Winsock.
Attempting connection to DBSERVE.
Socket for connection obtained.
Found service ‘FTP’ at port ‘21’.
Connection established to host ‘DBSERVE’ on port 21.
TCP/IP Communication Test Passed!
5.3. NetBEUI Tab
NetBEUI is supported on all Windows clients, but only Windows server platforms support NetBEUI as a
server.
Use this property sheet to test NetBEUI connectivity between the client and the server.
Embarcadero Technologies 64
Network Configuration
1. Select a Windows server on which InterBase has been installed from the Server Name drop-down
list. If the desired server does not exist in this list, you can type the server name in the edit portion
of the drop-down list.
2. Click Test to display the results of the connectivity test in the Results text area.
The connection may fail if a Microsoft Windows network is not the default network for the client. You should
also be logged into the Windows network with a valid user name and password.
Embarcadero Technologies 65
Database User Management
This chapter gives an overview of these options. The user administration tools are covered here, but SQL
statements for configuring privileges are in other InterBase books; these passages are referenced where
appropriate.
1. Security Model
Security for InterBase relies on a central security database for each server host. This database, admin.ib
by default, contains a record for each legitimate user who has permission to connect to databases and
InterBase services on that host. Each record includes the user login name and the associated encrypted
password. The entries in this security database apply to all databases on that server host.
The username is significant to 31 bytes and is not case sensitive. When a stronger password protection is
implemented, the password is now significant to 32 bytes instead of 8 and is case sensitive.
Before performing any database administration tasks, you must first log in to a server. Once you log in to
a server, you can then connect to databases residing on the server.
All users must enter their username and password to log in to a server. The password is encrypted for
transmission over the network. The username and password are verified against records in the security
database. If a matching record is found, the login succeeds.
Every InterBase server has a SYSDBA user, with default password masterkey. SYSDBA is a special user
account that can bypass normal SQL security and perform tasks such as database backups and shutdowns.
Initially, SYSDBA is the only authorized user on a server; the SYSDBA must authorize all other users on
the server. Only the SYSDBA user can update the security database to add, delete, or modify user config-
urations. SYSDBA can use either gsec or IBConsole to authorize a new user by assigning a username and
password in the security database.
Embarcadero Technologies 66
Database User Management
IMPORTANT
We strongly recommend you change the password for SYSDBA as soon as possible after installing InterBase. If you do
not alter the SYSDBA password, unauthorized users have easy access and none of your databases are secure.
Other Users
The SYSDBA account can create other users on a per-server basis. Use gsec or IBConsole to create, mod-
ify, or remove users from the InterBase security database. These users are authorized to connect to any
database on that database server host. It is a common design strategy to create a distinct InterBase user
for each person who uses the databases on your server. However, other strategies are also legitimate.
For example:
• Create one InterBase user for an entire group of people to use, in order to simplify password admin-
istration. For example, a user FINANCE could satisfy the access needs for any and all staff in a financial
analysis team. This team only needs to remember one password between them.
• Create one InterBase user for a group of people to use, as warranted by requirements of distinct
privilege configurations. For example, if Erin and Manuel have identical access to the data within a
database, they could use the same InterBase user account.
Users on UNIX
If both the client and the server are running UNIX, you can allow UNIX usernames access to databases by
configuring the server host to treat the client host as a trusted host.
To establish a trusted host relationship between two hosts, add an entry in /etc/hosts.equiv or /etc/
gds_hosts.equiv on the server. The former file establishes trusted host status for any service (for example,
rlogin, rsh, and rcp); the latter file establishes trusted host status for InterBase client/server connections
only. The format of entries in both files is identical; see your operating system documentation on hosts.e-
quiv for details.
The login of the client user must exist on the server. In addition to the hosts.equiv method of establishing
a trusted host, the you can also use the .rhosts file in the home directory of the account on the server
that matches the account on the client.
The InterBase client library defaults to using the current client’s UNIX login as the InterBase login only when
the client specifies no username through any of the following methods:
NOTE
• This feature is not implemented on Windows servers, because Windows does not implement a trusted host mech-
anism as UNIX does.
• Windows clients cannot be treated as trusted hosts by UNIX servers.
Embarcadero Technologies 67
Database User Management
NOTE
InterBase XE implements stronger password protection on InterBase databases. See Implementing Stronger Password
Protection.
You can use another name for the security database if you wish. If you change this name, you must add
an entry to the ibconfig file, setting ADMIN_DB to the new name.
ADMIN_DB newname.ib
NOTE
In older versions of InterBase, the security database was named isc4.gdb. Because files with a gdb extension automati-
cally get backed up whenever they are touched in some versions of Windows XP, using this extension degrades database
performance. Therefore, InterBase recommends using a different extension for database names.
Every user of an InterBase server requires an entry in the InterBase security database. The gsec security
utility lets you display, add, modify, or delete information in the security database. IBConsole provides a
graphical interface for the same functionality. The following table describes the contents of the security
database:
• Case sensitive
• Only the first eight bytes are significant
• Maximum length: 32 bytes.
UID No An integer that specifies a user ID.
GID No An integer that specifies a group ID.
Full name No User’s real name (as opposed to login name)
Requirements/Constraints
• This design supports server-wide user authentication as manifested by the USERS table of the secu-
rity database, configured with the IBCONFIG.ADMIN_IB property parameter, which defaults to the
admin.ib file.
Embarcadero Technologies 68
Database User Management
• The design also supports EUA (Embedded User Authentication) databases. As with the non-EUA
databases, it also has to be explicitly enabled by the owner/administrator. Please note that the USERS
table in admin.ib has RDB$USERS as the counterpart in EUA databases; so the earlier references have
to be compatible with EUA database references.
• A user account in the USERS table can only accommodate a single password hash value. This restriction
means that once the user account password is changed to use SHA-1, the user has to use the new
IB client to log into the new IB server.
• A plaintext password length of 32 bytes is supported in this release, up from 8 bytes in earlier versions
of InterBase.
• An updated version of IBConsole is present in the kit. This version does not show the “Default” buttons
in the database/server login screens.
• A batch script (changepassword.bat) is now provided in the <interbase>/bin directory to update the
SYSDBA account password post-install.
The DES-CRYPT password algorithm has been replaced with a modern cryptographic hash function that is
more widely accepted by organizations in private industry and government. The design uses SHA-1, which
generates a fixed length 160-bit hash.
1. Before starting, it is strongly recommended that you back up your old admin.ib from the current
installation before installing the new InterBase. This allows you to restore it, if needed.
2. After new IB has been installed on the server, run the following against admin.ib:
NOTE
The ALTER DATABASE command can only be run by the database owner or SYSDBA. This command modifies RDB
$DATABASE.RDB$PASSWORD_DIGEST to the string value "SHA-1". This means that all new password hash generation
for new or existing user accounts in the USERS table will use the SHA-1 hash function.
The password hash function can be reset to DES-CRYPT using the same DDL:
The admin database is now prepared so that new user accounts or modifying the password of existing
accounts will generate SHA-1 password hashes against plaintext passwords up to an untruncated length
of 32 significant bytes.
GSEC [add | modify], IBConsole, and the IB Services API support the SHA-1 password hash algorithm. Any of
these tools can be used to maintain the passwords of server-wide user accounts. If an existing user account
has had its password changed, then that user must log in to the server using the new IB client library.
Embarcadero Technologies 69
Database User Management
IMPORTANT
There will be backward compatibility problems if the converted admin.ib database is backed up and restored by an
older IB engine after the password hashes have been converted to SHA-1. Older IB engines will not understand the
different password hashes and will cause unrecoverable login errors.
Only the database owner is allowed to administer embedded user authentication. A regular user may alter
the password for their own user account.
Having a SYSDBA user account under embedded user authentication is optional. If there is a SYSDBA
account, it has most of the same privileges for the database in which it is embedded that any admin.ib
would have. The sole exception is that the SYSDBA cannot maintain admin control for EUA if it has been
implemented by another user.
IMPORTANT
EUA must be enabled to use the InterBase encryption feature, which facilitates the encryption of database pages and
columns. Access to encrypted databases and columns can be given to specified users when EUA has been enabled. For
more information about the InterBase encryption feature, see the Data Definition Guide.
Only the owner or SYSDBA can query for this information, once connected to the database. For all other
users, the info request is ignored.
The admin clause automatically inserts name and password information for the user creating the database
into the RDB$USERSsystem table.
Embarcadero Technologies 70
Database User Management
Alternatively, the gsec command-line utility has a new option, -user_database [database_name], which
allows that tool to maintain user accounts for embedded user authentication enabled databases.
Once EUA is disabled, access to the database will be authenticated via the centralized user authentication
database of the server ADMIN.IB.
You can enable EUA using the IBConsole when you use the IBConsole interface to create a new database.
1. Right-click on Databases and choose Create Database from the context menu.
2. On Create Database, in the Embedded User Authentication field, change the default, No, to Yes.
3. Change the other settings as needed, and choose OK to create the database. EUA is now enabled.
To add users to a EUA-enabled database, use the isc_spb_user_dbname service parameter block (SPB)
with the isc_action_svc_add_user service action. The allowed service actions are isc_action_svc_xxx_user,
where you replace xxx with add/modify/delete/display for each respective action.
The following code sample illustrates how to use this SPB to add a user to EUA-enabled database:
#ifdef EUA_DATABASE
*thd++ = isc_spb_user_dbname;
ADD_SPB_LENGTH (thd, strlen(target_db));
for (x = target_db; *x;)
*thd++ = *x++;
#endif
For more information about using this and other service parameter blocks and service actions, see the
InterBase API Guide.
• By default, PUBLIC users have only SELECT privileges on the system tables.
Embarcadero Technologies 71
Database User Management
• The database owner, the SYSDBA user, and the operating system administrator (root on UNIX and
Administrator on Windows server platforms) have full access to the system tables, including write
permission. These users can, if desired, assign write privileges to individual users or to PUBLIC, using
the GRANT statement.
Older Databases
InterBase applies this default security (no write access for PUBLIC) to older databases whenever possible:
• The gbak backup/restore utility applies the default security to any database when it is restored to ODS
10.1 (InterBase 6.5) or later.
• When an InterBase server that is version 6.5 or later attaches an older database, it applies the default
privileges to that database if they are not already present, even if the database is ODS 10.0 or earlier.
• readmeta.sql applies the default PUBLIC access privileges: PUBLIC can only select from the system
tables, but the database owner, system administrator, and SYSDBA user have full access. This script
can be used to return a database that has customized system table privileges back to this default.
• writemeta.sql grants all system table privileges to PUBLIC. This is the behavior that existed in InterBase
6.0 and earlier.
• blindmeta.sql revokes all system table privileges from PUBLIC. This prevents any PUBLIC user from
querying the system tables, including InterBase and third-party utilities run by PUBLIC users. For ex-
ample, gstat, gbak, QLI and IBConsole would not be able to query system metadata. This script allows
developers to protect their intellectual property by hiding the database design of tables, stored pro-
cedures and triggers from the general public and competitors. Blind access makes it difficult, if not
impossible, for a general user to generate ad hoc queries against a database.
A database with blind access does not prevent any user from using InterBase Data Definition Language
(DDL) to define new database objects. It just prevents a user from querying or writing to the system tables
directly.
Older InterBase clients InterBase 6.0 and previous InterBase kits cannot access a database on behalf of a
user if that user has no privileges to the system tables. Thus an InterBase developer who runs blindmeta.sql
on an InterBase database cannot ship that database to customers with InterBase 6.0 or older runtime kits
and expect those users to be able to access the database. The developer would have to run readmeta.sql
against a copy of the database and ship that to customers who have older InterBase runtimes.
Embarcadero Technologies 72
Database User Management
The InterBase engine automatically installs the default (SELECT-only) SQL privileges for PUBLIC on the system
tables when attaching ODS 10.0 or older databases. Thus if all users must be able to write to database
metadata, writemeta.sql will have to be run against each database to restore that behavior.
6. SQL Privileges
Connecting to a database does not automatically include privileges to modify or even view data stored
within that database. Privileges must be granted explicitly; users cannot access any database objects until
they have been granted privileges. Privileges granted to PUBLIC apply to all users.
For full description of syntax of SQL privileges, see entries for GRANT and ROLE in the Language Reference
and Data Definition Guide.
7. Groups of Users
InterBase implements features for assigning SQL privileges to groups of users. SQL roles are implemented
on a per-database basis. UNIX groups are implemented on a server-wide basis, using the UNIX group
mechanism.
SQL Roles
InterBase supports SQL group-level security as described in the ISO-ANSI Working Draft for Database
Language. For syntax of SQL ROLE, see Language Reference Guide and Data Definition Guide.
2. Assign privileges on specific tables and columns to the role using the GRANT statement.
4. Finally, to acquire the privileges assigned to a role, users must specify the role when connecting to
a database.
User1 now has update privileges on TABLE1 for the duration of the connection.
Embarcadero Technologies 73
Database User Management
A user can belong to only one role per connection to the database and cannot change role while con-
nected. To change role, the user must disconnect and reconnect, specifying a different role name.
You can adopt a role when connecting to a database by any one of the following means:
• To specify a role when attaching to a database through IBConsole isql, display the Database
Connect dialog and type a rolename in the Role field.
• To specify a role programmatically upon connection using the InterBase API, use the dpb
parameter isc_dpb_sql_role_name. See the API Guide.
• To specify a role for a connection made by an embedded SQL application or isql session,
use the ROLE <rolename> clause of the CONNECT statement. See the statement reference for CONNECT
in the Language Reference Guide.
NOTE
Applications using BDE version 5.02 or later, including Delphi, JBuilder, and C++Builder, have a property by which they
can specify a role name. Also, the ODBC driver that currently ships with InterBase also recognizes roles.
UNIX Groups
Operating system-level groups are implicit in InterBase security on UNIX, similarly to the way UNIX users
automatically supplement the users in the InterBase security database. For full description of usage and
syntax of using UNIX groups with InterBase security, see Language Reference Guide and Data Definition
Guide.
NOTE
Integration of UNIX groups with database security is not a SQL standard feature.
As a security measure, InterBase requires that only the owner of a database or SYSDBA can execute gbak,
gstat, and gfix.
• Only the database owner or SYSDBA can use gbak to back up a database. Anyone can restore a
database, because there is no concept of an InterBase user for a backup file. However, only the owner
or SYSDBA can restore a database over an existing database. For security purposes, make sure that
your backup files are stored in a secure location. This prevents unauthorized persons from restoring
databases and gaining access to them.
• On UNIX platforms, there is a further constraint on gstat: to run gstat, you must have system-level
read access to the database file. To access the database with gstat, you must either be logged into the
account running the InterBase server (“InterBase” or “root”) or someone must change the permissions
on the database file to include read permission for your Group.
Embarcadero Technologies 74
Database User Management
You can take several steps to increase the security of your databases and other files on your system:
• UNIX and Linux systems: Before starting the InterBase server, log in as user “InterBase” (or “interbas”, if
user names longer than eight characters are not allowed), rather than “root” (only these users can start
the server). This restricts the ability of other users to accidentally or intentionally access or overwrite
sensitive files such as the password file. Start the InterBase server while you are logged on as user
“InterBase”.
• Windows server platforms: When the InterBase server is run as a service, you can protect a database
against unauthorized access from outside InterBase (such as by a copy command), by making the
database files readable only by the system account, under which services run. However, if you make
the database readable only by the system account, remote access to the database must be by TCP/
IP, not by NetBEUI.
• Because anyone can restore a backed up database, it is wise to keep your backup files in a directory
with restricted access. On UNIX, only the backup file itself, not the directory in which it resides, needs
to have permissions restricted to prevent reading by unauthorized persons.
then persons other than the responsible owner and group can see that the backup file is there, but they
cannot get at it. If the user or backup script issues the command umask 077 (or 027, as appropriate)
before running gbak, unauthorized persons will not be able to access the backup file, no matter what
the permissions on the directory. The directory should not be writable by “other”, since this permits other
persons to delete the backup file.
You can use any of the following methods to access the User Information dialog:
• Select a logged in server or any branch under the server hierarchy from the list of registered servers
in the Tree pane; choose Server|User Security.
• Select a logged in server from the list of registered servers in the Tree pane. Double-click User Security
in the Work pane or right-click the selected server and choose User Security from the context menu.
• Select Users under the desired server in the Tree pane to display a list of valid users in the Work pane.
Double-click a user name to display the User Information dialog.
Embarcadero Technologies 75
Database User Management
Adding a User
Use the User Information dialog to add new users. To access this dialog follow one of the methods described
in Displaying the User Information Dialog.
NOTE
Usernames can be up to 31 bytes long and are not case sensitive. Passwords are case-sensitive and only the first eight
characters are significant. InterBase does not allow you to create usernames or passwords containing spaces.
Use the User Information dialog to modify user configurations. To access this dialog follow one of the
methods described in Displaying the User Information Dialog.
Embarcadero Technologies 76
Database User Management
1. Display the User Information dialog in one of the following two ways:
• Select a logged in server or any branch under the server hierarchy from the list of registered servers
in the Tree pane; choose Server|User Security to display the User Information dialog.
• Select a logged in server from the list of registered servers in the Tree pane. Double-click User Security
in the Work pane or right-click the selected server and choose User Security from the context menu.
• Select Users under the desired server in the Tree pane to display a list of valid users in the Work pane.
Double-click a user name to display the User Information dialog.
2. From the User Name drop-down list, select the user whose configuration you wish to modify. The user’s
details display. You can also type the first letter of the desired username in the User Name drop-down list
to quickly scroll to usernames beginning with that letter. By repeatedly typing that same letter, you can
scroll through all usernames that begin with that letter.
3. Change any of the text fields except the User Name. If you change the password, you must enter the
same password in the Password text field and the Confirm Password text field.
You cannot modify a username. The only way to change a username is to delete the user and then add
a user with the new name.
Deleting a User
Use the User Information dialog to removed users from the security database. To access this dialog follow
one of the methods described in Displaying the User Information Dialog.
1. Display the User Information dialog in one of the following two ways:
• Select a logged in server or any branch under the server hierarchy from the list of registered servers
in the Tree pane; choose Server|User Security.
• Select a logged in server from the list of registered servers in the Tree pane. Double-click User
Security in the Work pane or right-click the selected server and choose User Security from the
context menu.
2. Select the user you wish to delete from the User Name drop-down list. You can also type the first letter
of the desired username in the User Name drop-down list to quickly scroll to usernames beginning
with that letter. By repeatedly typing that same letter, you can scroll through all usernames that begin
with that letter.
3. Click Delete. A confirmation dialog inquires, “Do you wish to delete user username?” If you choose
OK, the user is removed and is no longer authorized to access databases on the current server.
IMPORTANT
Although it is possible for the SYSDBA to delete the SYSDBA user, it is strongly not recommended because it will no
longer be possible to add new users or modify existing user configurations. If you do delete the SYSDBA user, you must
reinstall InterBase to restore the InterBase security database (admin.ib by default).
Embarcadero Technologies 77
Database User Management
The InterBase Services API provides a much broader and more robust set of tools for programmatically
managing users in the security database. See “Working with Services” in the API Guide for details and
examples of using the Services API functions.
For programmers using Delphi and C++Builder, the IBX components include components for managing
users. For more information on using the IBX components, refer to the Developer's Guide.
The security database resides in the InterBase install directory. To connect to a database on the server,
users must specify a user name and password, which are verified against information stored in the security
database. If a matching row is found, the connection succeeds.
IMPORTANT
Only the SYSDBA can run gsec. To do this, use one of the following methods:
• Define the ISC_USER and ISC_PASSWORD environment variables for SYSDBA before you invoke the
command.
• Run gsec when you are logged in as root on UNIX or Administrator on Windows.
To use gsec interactively, type gsec at the command prompt. The prompt changes to GSEC>, indicating
that you are in interactive mode. To quit an interactive session, type QUIT.
Embarcadero Technologies 78
Database User Management
For example:
Command Description
di[splay] Displays all rows of the InterBase security database (admin.ib by default)
di[splay]name Displays information only for user <name>
a[dd]name-pw password Adds user <name> to the security database with password <string>. Each option and cor-
[option argument] responding argument specify other data associated with the user, as shown in Adding En-
[option argument ...] tries to the Security Database
mo[dify]name [options] Like add, except that <name> already exists in the security database
de[lete]name Deletes user <name> from the security database
alias_add path name Adds a database alias. The path is the location of the database, and <name> is the name
given for the alias
alias_del name Deletes database alias <name> from the security database
alias_dis Displays all database alias
alias_dis name Displays information only for alias <name>
h[elp] or ? Displays gsec commands and syntax
q[uit] Quits the interactive session
GSEC> display
user name uid gid full name
----------------------------------------------
JOHN 123 345 John Doe
JANE 124 345 Jane Doe
RICH 125 345 Richard Roe
Embarcadero Technologies 79
Database User Management
followed by a user name, the -pw option followed by a password, and any other options, as shown in the
following table. The password is case sensitive. None of the other parameters are case sensitive.
For each option, the initial letter or letters are required, and optional parts are enclosed in brackets. Each
option must be followed by a corresponding argument, a string that specifies the data to be entered into
the specified column in the InterBase security database (admin.ib by default).
Option Meaning
-password or -pastring Password of user who is performing the change
-userstring User who is performing the change
-pwstring Target user password
-uidinteger Target user ID
-gidinteger Group ID for target user
-fnamestring First Name for target user
-mnamestring Middle Name for target user
-lnamestring Last Name for target user
-user_databasestring Name of user database
-databasestring Name of remote security database
NOTE
The -pa switch specifies the root or the SYSDBA account password; -pw specifies the password for the user being added
or modified.
For example, to add user “jones” and assign the password “welcome”, enter:
GSEC> display
user name uid gid full name
----------------------------------------------
JONES 0 0
For example, to add authorization for a user named Cindi Brown with user name “cbrown” and password
“coffee2go”, use the following gsec command:
To verify the new entry, display the contents of the security database:
GSEC> display
user name uid gid full name
Embarcadero Technologies 80
Database User Management
----------------------------------------------
JONES 0 0
CBROWN 0 0 CINDI BROWN
For example, to set the user ID of user “cbrown” to 8 and change the first name to “Cindy”, enter the
following commands:
To verify the changed line, use display followed by the user name:
NOTE
To modify a user name, first delete the entry in the security database, then enter the new user name and re-enter the
other information.
You can confirm that the entry has been deleted with the display command.
Embarcadero Technologies 81
Database User Management
To add database alias to the security database, use the alias_add command:
For example, to add the database alias "emp" with the path "C:\Embarcadero\InterBase\exam-
ples\database\employee.ib", enter:
NOTE
To delete a database alias from the security database, use the alias_del command:
alias_del name
Embarcadero Technologies 82
Database User Management
Error in switch specifications This message accompanies other error messages and indicates that invalid syntax was
used. Check other error messages for the cause.
Find/delete record error Either the delete command could not find a specified user, or you do not have appro-
priate privilege to use gsec.
Find/display record error Either the display command could not find a specified user, or you do not have ap-
propriate privilege to use gsec.
Find/modify record error Either the modify command could not find a specified user, or you do not have appro-
priate privilege to use gsec.
Incompatible switches specified Correct the syntax and try again.
Invalid parameter, no switch de- You specified a value without a preceding argument.
fined
Invalid switch specified You specified an unrecognized option. Fix it and try again.
Modify record error Invalid syntax for modify command. Fix it and try again.
Embarcadero Technologies 83
Database Configuration and Maintenance
1. Database Files
InterBase database files are in many cases self-contained. All the data and indexes are maintained as data
structures within one type of file. The transaction log is also kept within this file.
You can extend the functions available in InterBase database metadata by creating libraries of functions
compiled in your language of choice. You can compile functions into a dynamic library (called a DLL on
Windows, and a shared library on UNIX) and use them in queries, stored procedures, triggers, views, and
so on.
InterBase supports 64-bit file IO, so the size of a database file is effectively limited only by the operating
system.
NOTE
Using gbak is the only way to reduce the size of the primary database file. When you restore a database, you can specify
multiple files without reference to the original file sizes.
Example:
Embarcadero Technologies 84
Database Configuration and Maintenance
By default, creating a database does not preallocate additional database pages, so it is as if NO PREALLOCATE
had been specified. IB provides this syntax so that a DDL script can explicitly state and document that
preallocation has not been specified. Database preallocation is always specified in units of database pages
to be consistent with other related features (i.e., length of secondary database files or shadow sets).
IMPORTANT
If a preallocation exceeds available disk space, the IB thread making the write request when the device fills will timeout
after 1 minute of waiting for the I/O to complete. It makes 4 additional I/O attempts, waiting 1 minute each time, to
complete the write (results written to the InterBase log). If space is not freed to allow the preallocation operation to
continue, the space requested will not be allocated.
Example:
With the InterBase service API, actions isc_action_svc_backup (isc_action_svc_restore) take new parameters,
isc_spb_bkp_preallocate (isc_spb_res_preallocate), respectively. Both parameters take a 4-byte argument
to specify the database preallocation in units of database pages. The service parameters have the same
numeric value but two symbolic constants are provided for source code clarity to show the proper intent.
NOTE
See “Working with Databases” in the API Guide for more information about DPB parameters.
1.2. External Files
InterBase permits external files to be used as external tables. These tables are limited in their functionality:
• From a database that is in read-write mode, you can execute only SELECT and INSERT statements on
external tables. From a read-only database, you can execute only SELECT statement on external tables.
Embarcadero Technologies 85
Database Configuration and Maintenance
• You cannot define indexes on external tables; they are outside of the control of the multigenerational
architecture.
• The 2GB external file size limit has been removed from InterBase XE onward.
The default location for external files is <InterBase_home>/ext. InterBase can always find external files that
you place here. If you want to place them elsewhere, you must specify the location in the ibconfig con-
figuration file using the EXTERNAL_FILE_DIRECTORY entry.
IMPORTANT
For security reasons, it is extremely important that you not place files with sensitive content in the same directory with
external tables.
NOTE
Migration note: If you are migrating from InterBase 6.x or older to InterBase 7.x or newer, and your database includes
external table files, you must either move these files to <InterBase_home>/ext or note their locations in ibconfig
using the EXTERNAL_FILE_DIRECTORY entry.
1.3. Temporary Files
InterBase dynamically creates files in the temporary file space for scratch space during sorting operations
involving large amounts of data. See Managing Temporary Files for details on temporary file use.
InterBase is available on a wide variety of platforms. In most cases users in a heterogeneous networking
environment can access their InterBase database files regardless of platform differences between client
and server machines if they know the file naming conventions of the target paltform.
Generally, InterBase fully supports each file naming conventions of a platform, including the use of node
and path names. InterBase, however, recognizes two categories of file specification in commands and
statements that accept more than one file name. The first file specification is called the primary file specifi-
cation. Subsequent file specifications are called secondary file specifications. Some commands and state-
ments place restrictions on using node names with secondary file specifications. In syntax statements, file
specification is denoted as '<filespec>'
Embarcadero Technologies 86
Database Configuration and Maintenance
In this syntax, the <filespec> that follows CREATE DATABASE supports a node name and path specification,
including a platform-specific drive or volume specification.
1.5. Multifile Databases
InterBase supports databases that span multiple files and multiple file systems. You can add additional files
to the database without having to take it off line.
The Database Restore task in IBConsole and in the gbak command-line utility permit you to create a
multifile database. The only way to alter the file size allocation of an existing database is to back up and
restore the database file.
CONNECT ‘first.ib’;
ALTER DATABASE
ADD FILE 'second.ib' STARTING AT 50000;
The following isql example adds a file using LENGTH syntax. second.ib will begin on the page following the
final page of first.ib and will grow to 50,000 database pages. Then InterBase begins writing to third.ib
and dynamically increases the size as necessary.
CONNECT 'first.ib';
ALTER DATABASE ADD FILE 'second.ib' LENGTH 50000
ADD FILE 'third.ib';
Embarcadero Technologies 87
Database Configuration and Maintenance
InterBase starts writing data to third.ib only after second.ib file fills up. In the example above, second.ib
is 50,000 pages long, and begins following the original file. InterBase will begin filling the third.ib file after
second.ib reaches 50,000 pages. Database pages are 4KB each by default and have a maximum size of 8KB.
There is no guarantee that a given table resides entirely in one file or another. InterBase stores records
based on available space within database files. Over time, records from a given table tend to spread over
all the files in a multifile database.
1.5.4. Application Considerations
A multifile database is not the same thing as multiple single-file databases. The tables are all part of the
same database they used to be in, but they can be stored across the multiple files. From the standpoint
of your application, they are all part of the same database and are accessed exactly the same way they
would be in a single-file database.
Your application does not need to know about any files except the first one. Any time your database
operations access/write data in the secondary files, the InterBase software takes care of it without requiring
any special programming from your application. The application attaches to the database by specifying
the path of the first file of the database; applications do not change.
TIP
Any database in a production environment should include a definition for at least one secondary file, even if the current
size of the database does not warrant a multifile database. Data tends to accumulate without bounds, and some day
in the future your database might exceed your file system size, or the maximum file size of the operating system. By
defining a secondary file, you specify what action InterBase takes when the database grows beyond these limits. This
means that the database administrator is freed from monitoring the database as it approaches the file size limit.
On UNIX, the InterBase software detects that a database file is located on an NFS file system. In this case,
it invokes the remote access method to contact an InterBase server process running on the host that
exported the file system. If there is no InterBase server software running on that node, any connection
to the database fails.
Embarcadero Technologies 88
Database Configuration and Maintenance
The InterBase 2017 format is ODS 17, but still supports existing databases with ODS 16 through 13. Older
ODS version are not supported and can not be connected to. It is strongly recommended to back up and
restore your database so it can be upgraded to ODS 17 and benefit from the newer features.
When you create a new database or restore a backup file in the current version of InterBase, the result-
ing database file has the current ODS version.
IMPORTANT
To upgrade the ODS of an older database, you must back it up using the backup utility for the version of the existing
database and then restore it using the current version of InterBase.
3.1. Read-write Databases
To function in read-write mode, databases must exist on writable media and the ibserver process must
have write access to the database file. For databases that are in read-write mode, this is true even when
they are used only for reading because the transaction states are kept in an internal inventory data structure
within the database file. Therefore any transaction against the database requires the ability to write to the
transaction inventory.
Under both Windows and UNIX, read-write database files must be writable by the user ID for the ibserver
process. However, the operating environment or file system can be configured to create files that have
limited file privileges by default. If you attempt to attach to a database and get an error of “unavailable
database,” first check to see if the permissions of the database file are such that the user ID of the ibserver
process does not have write privilege on the database file.
3.2. Read-only Databases
You can change InterBase databases to read-only mode. This provides enhanced security for databases by
protecting them from accidental or malicious updates and enables distribution on read-only media such
as CDROMs. Databases are always in read‑write mode at creation time. This feature is independent of
dialect. Any ODS 10 or higher database can be set to read-only mode.
You can use gbak, gfix, or IBConsole to change a database to read-only mode. (See Making a Database
Read-only below.)
Embarcadero Technologies 89
Database Configuration and Maintenance
• Attempted INSERT, UPDATE, and DELETE operations on a read-only database generate an error. See the
“Error Codes and Messages” chapter of the Language Reference Guide.
• No metadata changes are allowed in read-only databases.
• Generators in a read-only database do not increment and are allowed only to return the current value.
For example, in a read-only database, the following statement succeeds:
The following statement fails with the error “attempted update on read-only database.”
• External files accessed through a read-only database open in read-only mode, regardless of the file’s
permissions at the file system level.
From within InterBase, you can change a read-write database to read-only mode in any of three ways:
• In IBConsole, select the database, display its properties, and edit the mode. For more information,
refer to Setting Database Properties.
• Use gbak to back up the database and restore it in read-only mode:
IMPORTANT
To set a database to read-only mode from any application that uses BDE, ODBC, or JDBC, use the isc_action_svc_prop-
erties() function in the InterBase Services API.
TIP
To distribute a read-write database on a CD-ROM, back it up and put the database.ibk file on the CD-ROM. As part of
the installation, restore the database to the user’s hard disk.
Embarcadero Technologies 90
Database Configuration and Maintenance
4. Creating Databases
You can create databases on local and remote servers using IBConsole with the Create Database dialog.
You can use any of the following methods to access the Create Database dialog:
• In the Tree pane, select a server or anywhere in the branch under the desired server and choose
Database|Create Database.
• In the Tree pane, right click the Databases branch under the desired server, and select Create
Database from the context menu.
To Create a Database:
1. Ensure that the server indicated is correct. If it is not, cancel this dialog and re-initiate it under the
correct server.
2. Type an Alias name for the new database in the Alias text field.
3. Enter one or more filenames which will make up the database, specifying the number of pages re-
quired for each file. To insert a new row into the Files table, move to the last row and column of the
table and type W‑Z.
Embarcadero Technologies 91
Database Configuration and Maintenance
When entering a filename, make sure to include the file path unless you wish to default the file to the
working directory.
NOTE
4. You can specify create options by entering a valid value, by clicking the option value and choosing a
new value from a drop-down list of values or by double-clicking the option value to rotate its value
to the next in the list of values. For more information, see Database Options below.
To create a basic database without any options, leave all options blank.
IMPORTANT
The alias name that you specify when creating a database references the necessary database file information associated
with the database. When performing database configuration and maintenance, you need to specify only the alias name,
not the actual database filename. If the database spans multiple files, the server uses the header page of each file to
locate additional files.
4.1. Database Options
The database options that you can set are Page Size, Default Character Set, and SQL dialect.
4.1.1. Page Size
InterBase supports database page sizes of 1024, 2048, 4096, 8192, and 16384 bytes. The default is 4096
bytes.
For more information about creating databases, see the Language Reference Guide. See the Data Defini-
tion Guide for an explanation of character sets.
4.1.3. SQL Dialect
An InterBase database SQL dialect determines how double quotes, large exact numerics, and certain data
types such as SQLDATE, TIME, and TIMESTAMP are interpreted. In most cases you should create databases
in dialect 3 in order to have access to all current InterBase features.
Changing a database dialect from 1 to 3 may require some preparation if it contains DATE data types,
DECIMAL or NUMERIC data types with precision greater than 9, or has strings that are in double quotes
rather than single quotes. For more information about dialects, refer to Understanding SQL Dialects in the
migration appendix of the Operations Guide.
1. Highlight the database in the Tree pane and perform one of the following actions:
• Choose Database|Properties.
Embarcadero Technologies 92
Database Configuration and Maintenance
TIP
To suppress the display of system tables in IBConsole, deselect System Data from the View menu.
5. Dropping Databases
You can drop databases using IBConsole. Dropping a database deletes the current database and database
alias, removing both data and metadata.
To Drop a Database:
IMPORTANT
• Expand Backup in the Tree pane, select a backup alias, and double-click Modify Backup Alias from
the Work pane.
• Right-click a backup alias in the Tree pane and choose Modify Backup Alias from the context menu.
Embarcadero Technologies 93
Database Configuration and Maintenance
1. Enter a new backup alias name in the Alias Name text field.
2. Add, remove, or modify the backup filenames and corresponding file sizes associated with the backup
in the backup files table. When specifying filenames, be sure to include the file path where the file
is located.
To add a new row to the backup files table, move to the last row and column of the table and type W‑Z.
To remove a file from the backup file list, delete the values from the table.
3. Select a server from the Target Database Server drop-down list. You can also type the server name
in the edit portion of the drop-down list.
4. Select a database alias from the Target Database Alias drop-down list. You can also type the alias
name in the edit portion of the drop-down list.
5. Click Apply to save your changes.
• Expand Backup in the Tree pane and select a backup alias and double-click Delete Alias from the
Work pane.
• Right-click a backup alias in the Tree pane and choose Delete Alias from the context menu.
A dialog asks you to confirm that you wish to remove the selected backup file. Click Yes if you want to
delete the backup file, otherwise click No.
8. Shadowing
InterBase lets you recover a database in case of disk failure, network failure, or accidental deletion of
the database. The recovery method is called disk shadowing, or sometimes just shadowing. This chapter
describes how to set up and use shadowing.This section describes the various tasks involved in shadowing,
as well as the advantages and limitations of shadowing.
1. Creating a shadow.
Shadowing begins with the creation of a shadow. A shadow is an identical, physical copy of a database.
When a shadow is defined for a database, changes to the database are written simultaneously to its shadow.
In this way, the shadow always reflects the current state of the database. For information about the different
ways to define a shadow, see Creating a Shadow.
2. Activating a shadow.
If something happens to make a database unavailable, the shadow can be activated. Activating a shadow
means it takes over for the database; the shadow becomes accessible to users as the main database.
Activating a shadow happens either automatically or through the intervention of a database administra-
Embarcadero Technologies 94
Database Configuration and Maintenance
tor, depending on how the shadow was defined. For more information about activating a shadow, see
Activating a Shadow.
3. Deleting a shadow.
If shadowing is no longer desired, it can be stopped by deleting the shadow. For more information about
deleting a shadow, see Dropping a Shadow.
A shadow can consist of more than one file. As shadows grow in size, files can be added to accommodate
the increased space requirements. For more information about adding shadow files, see Adding a Shadow
File.
8.2. Advantages of Shadowing
Shadowing offers several advantages:
8.3. Limitations of Shadowing
Shadowing has the following limitations:
8.4. Creating a Shadow
A shadow is created with the CREATE SHADOW statement in SQL. Because this does not require exclusive
access, it can be done without affecting users. For detailed information about CREATE SHADOW, see the
Language Reference.
Embarcadero Technologies 95
Database Configuration and Maintenance
A shadow should be created on a different disk from where the main database resides. Because shadowing
is intended as a recovery mechanism in case of disk failure, maintaining a database and its shadow on the
same disk defeats the purpose of shadowing.
A shadow can be created as a single disk file called a shadow file or as multiple files called a shadow set.
To improve space allocation and disk I/O, each file in a shadow set can be placed on a different disk.
If a shadow becomes unavailable, InterBase can either deny user access to the database until shadowing
is resumed, or allow access even though database changes are not being shadowed. Depending on which
database behavior is desired, the database administrator creates a shadow either in auto mode or in
manual mode. For more information about these modes, see Auto Mode and Manual Mode.
To ensure that a new shadow is automatically created, create a conditional shadow. For more information,
see Conditional Shadows in this chapter.
The next sections describe how to create shadows with various options:
These choices are not mutually exclusive. For example, you can create a single-file, conditional shadow
in manual mode.
The name of the shadow file is employee.shd, and it is identified by the number 1. Verify that the shadow
has been created by using the isql command SHOW DATABASE:
The page size of the shadow is the same as that of the database.
Embarcadero Technologies 96
Database Configuration and Maintenance
databases, you have the option of specifying the size of secondary files in either of two ways: specify the
page on which each secondary file starts, or specify the length in database pages of each file. When you
specify the size using the LENGTH keyword, do not specify the length of the final file. InterBase sizes the
final file dynamically, as needed.
For example, the following example creates a shadow set consisting of three files. The primary file, employ-
ee.shd, is 10,000 database pages in length. The second file is 20,000 database pages long, and the final
file grows as needed.
Instead of specifying the page length of secondary files, you can specify their starting page. The following
example creates the same shadows as the previous example:
In either case, you can use SHOW DATABASE to verify the file names, page lengths, and starting pages for
the shadow just created:
The page length you allocate for secondary shadow files need not correspond to the page length of the
secondary files of the database. As the database grows and its first shadow file becomes full, updates to
the database automatically overflow into the next shadow file.
Embarcadero Technologies 97
Database Configuration and Maintenance
The database administrator might be unaware that the database
is operating without a shadow
Manual Prevents the database from running un- Database operation is halted until the problem is fixed
intentionally without a shadow
Needs intervention of the database administrator.
8.4.3.1. Auto mode
The AUTO keyword directs the CREATE SHADOW statement to create a shadow in auto mode:
Auto mode is the default, so omitting the AUTO keyword achieves the same result.
In AUTO mode, database operation is uninterrupted even though there is no shadow. To resume shadowing,
it might be necessary to create a new shadow. If the original shadow was created as a conditional shadow,
a new shadow is automatically created. For more information about conditional shadows, see Conditional
Shadows.
8.4.3.2. Manual mode
The MANUAL keyword directs the CREATE SHADOW statement to create a shadow in manual mode:
Manual mode is useful when continuous shadowing is more important than continuous operation of the
database. When a manual-mode shadow becomes unavailable, further attachments to the database are
prevented. To allow database attachments again, the database owner or SYSDBA must enter the following
command:
This command deletes metadata references to the unavailable shadow corresponding to <database>.
After deleting the references, a new shadow can be created if shadowing needs to resume.
8.4.4. Conditional Shadows
You can define a shadow in a way that if that shadow replaces a database, the server creates a new shadow
file. This allows shadowing to continue uninterrupted. A shadow defined with this behavior is called a
conditional shadow.
To create a conditional shadow, specify the CONDITIONAL keyword with the CREATE SHADOW statement.
For example,
Creating a conditional file directs InterBase to automatically create a new shadow. This happens in either
of two cases:
Embarcadero Technologies 98
Database Configuration and Maintenance
8.5. Activating a Shadow
When a database becomes unavailable, database operations are resumed by activating the shadow. To
do so, log in as SYSDBA or the database owner and use gfix with the -activate option.
IMPORTANT
Before activating a shadow, check that the main database is unavailable. If a shadow is activated while the main database
is available, the shadow can be corrupted by existing attachments to the main database.
To activate a shadow, specify the path name of its primary file. For example, if database employee.ib has
a shadow named employee.shd, enter:
After a shadow is activated, you should change its name to the name of your original database. Then,
create a new shadow if shadowing needs to continue and if another disk drive is available.
8.6. Dropping a Shadow
To stop shadowing, use the shadow number as an argument to the DROP SHADOW statement. For ex-
ample,
If you need to look up the shadow number, use the isql command SHOW DATABASE.
IMPORTANT
DROP SHADOW deletes shadow references from a database’s metadata, as well as the physical files on disk. Once the
files have been removed from disk, there is no opportunity to recover them. However, a shadow is merely a copy of an
existing database, so the new shadow is identical to the dropped shadow.
The page length you allocate for secondary shadow files need not correspond to the page length of the
database’s secondary files. As the database grows and its first shadow file becomes full, updates to the
database automatically overflow into the next shadow file.
• Select a connected database (or any branch under the database hierarchy) in the Tree pane and
choose Database|Properties.
• Select a connected database in the Tree pane and double-click Properties in the Work pane.
Embarcadero Technologies 99
Database Configuration and Maintenance
• Right-click a connected database in the Tree pane and choose Properties from the context menu.
The Database Properties dialog contains two tabs, Alias and General.
9.1. Alias Tab
The Alias tab of the Database Properties dialog is where you can specify an alias name for a database as
well as the file path and file name of the selected database.
1. Enter the alias name of the database in the Alias Name text field.
2. Enter database file name, including the path where the file is located, in the File text field. If you prefer,
you can also click the browse button to locate the file you want.
If you want to change the database file name, the database must be disconnected before you access the
Database Properties dialog.
3. If you need to view or configure the general database settings, click the General tab and see General
Tab below for further information.
4. Once you are finished making changes to the database properties click OK to save your changes,
otherwise click Cancel.
9.2. General Tab
The General tab of the Database Properties dialog is where you can view such database settings as the
database owner, secondary files and their start pages, the number of allocated database pages and the
page size. You can also set such options as Forced Writes, Sweep Interval, SQL Dialect and Read Only.
1. Choose option values in the Options table. You can specify options by clicking the option value and
entering a new value, by choosing a new value from a drop-down list of values or by double-clicking
the option value to rotate its value to the next in the list of values.
2. If you need to view or configure the database alias settings, click the Alias tab and see Alias TAb
above for further information.
3. Once you are finished making changes to the database properties click OK to save your changes,
otherwise click Cancel.
General Options
Option Value
Read Only Option values are True and False. To make the database read only set the Read Only op-
tion to True. This prevents users from performing any DML or updates to the database.
The default setting for this option is False. See Read-write and Read-only Databases for
more information.
Write Mode Sets the database write mode. Available options are Asynchronous, Synchronous and Di-
rect I/O
Sweep Interval The sweep interval is the number of transactions that will occur before an automatic
database sweep takes place. You can enter any positive number for the sweep interval, or
zero to disable the automatic sweep. See Sweep Interval and Automated Housekeeping
for further information on setting the sweep interval.
Database dialect An InterBase database SQL dialect determines how double quotes, large exact numerics,
and certain data types such as SQLDATE, TIME, and TIMESTAMP are interpreted. In most
cases you should choose dialect 3 in order to have access to all current InterBase features.
Page Buffers Enter a numeric value. It lets you set the number of database page buffers.
Linger Interval Set a value in seconds. It allows a database to remain in memory after the last user de-
taches.
Flush Interval Enables database flush. The interval <number> is interpreted in units of seconds
Reclaim Interval Set a value in seconds. Determines how often the garbage collector thread will run to re-
lease memory from unused procedures, triggers, and internal system queries back to In-
terBase memory heap.
Group Commit Available options are Yes and No when enabled allows transactions to be committed by a
background cache writer thread.
Reserve Table Space Available options are Yes and No. When set to No it disables space reservation on the
database.
Embedded User Authentica- Option Values are Disabled and Enabled. Stores database user name and password infor-
tion mation directly in the database.
InterBase databases periodically need to be swept. Otherwise, the main memory allocated for the bitmap
of each translation increases to the point where performance becomes unacceptable. The longer sweep
takes to complete, the more main memory requirements increase for starting new transactions.
10.1. Fast Sweep
With the implementation of the fast sweep optimization starting with InterBase XE, the memory allocation
issue has been mitigated. The user has the option to configure their databases for automatic sweep. In
cases where large databases have large archival or infrequently modified tables, a database sweep will
have minimal impact on the performance of running transactional operations.
Only ODS 15 and later databases can perform fast database sweeps. The effectiveness of a fast sweep is
directly proportional to the fraction of database data pages that have been modified since the last sweep.
If every data page has been changed, fast sweep is no faster than the former methodology. If very few
pages are changed, fast sweep is nearly instantaneous. If half the pages were updated, fast sweep is then
half the former sweep time.
Starting with InterBase XE7, any database that you restore is immediately marked as swept, therefore the
first sweep of that database is a fast sweep. This feature is available starting with InterBase XE7 and onwards.
There is no new user interface or action required by the user to enable fast sweep functionality. Manual
sweep initiated by the GFIX command line tool, IBConsole, or programmatically, as well as automatic sweep
configuration on a database, use the fast sweep mechanism.
As a database administrator, you can tune database sweeping, balancing its advantages and disadvantages
to best satisfy the needs of the users.
10.2. Overview of Sweeping
InterBase uses a multigenerational architecture. This means that multiple versions of data records are stored
directly on the data pages. When a record is updated or deleted, InterBase keeps a copy of the old state
of the record and creates a new version. This can increase the size of a database.
10.2.1. Garbage Collection
To limit the growth of the database, InterBase performs garbage collection by sweeping the database. This
process frees up space allocated to outdated record versions. Whenever a transaction accesses a record,
outdated versions of that record are collected. Records that were rolled back are not collected. To guarantee
that all outdated records are collected, including those that were rolled back, InterBase periodically sweeps
the database.
10.2.2. Automatic Housekeeping
If a transaction is left in an active (unresolved) state, this is an “interesting” transaction. In a given transaction
inventory of a database, the first transaction with a state other than committed is known as the Oldest
Interesting Transaction (OIT). Automatic housekeeping occurs when the difference between the OIT and
the oldest active transaction (OAT) is greater than the sweep interval. By default, this sweep interval is
20,000, but it is configurable (see Setting the Sweep Interval).
NOTE
It is a subtle but important distinction that the automatic sweep does not necessarily occur every 20,000 transactions.
It is only when the difference between the OIT and OAT reaches the threshold. If every transaction to the database is
committed promptly, then this difference it is not likely to be great enough to trigger the automatic sweep.
The InterBase server process initiates a special thread to perform this sweep asynchronously, so that the
client process can continue functioning, unaffected by the amount of work done by the sweep.
TIP
Sweeping a database is not the only way to perform systematic garbage collection. Backing up a database achieves the
same result, because the InterBase server must read every record, an action that forces garbage collection throughout
the database. As a result, regularly backing up a database can reduce the need to sweep. This enables you to maintain
better application performance. For more information about the advantages of backing up and restoring, see About
InterBase backup and restore options.
10.2.3. Configuring Sweeping
You are able to control several aspects of database sweeping. You can:
The first two functions are performed in the Database Properties dialog. The last is performed with a sweep
menu command and is explained in Performing an Immediate Database Sweep.
gfix -h n
Sweeping a database can affect transaction start-up if rolled back transactions exist in the database. As
the time since the last sweep increases, the time for transaction start-up can also increase. Lowering the
sweep interval can help reduce the time for transaction start-up.
On the other hand, frequent database sweeps can reduce application performance. Raising the sweep in-
terval could help improve overall performance. The database administrator should weigh the issues for the
affected applications and decide whether the sweep interval provides the desired database performance.
To set the sweep interval with IBConsole, refer to Setting Database Properties.
TIP
Unless the database contains many rolled back transactions, changing the sweep interval has little effect on database
size. As a result, it is more common for a database administrator to tune the database by disabling sweeping and
performing it at specific times. These activities are described in the next two sections.
• Right click a connected database in the Tree pane and choose Maintenance|Sweep from the context
menu.
• Select a connected database in the Tree pane and double-click Sweep in the Work pane.
• Enter the following command:
gfix -sweep
This operation runs an immediate sweep of the database, releasing space held by records that were rolled
back and by out-of-date record versions. Sweeps are also done automatically at a specified interval.
Sweeping a database does not strictly require it to be shut down. You can perform sweeping at any time,
but it can impact system performance and should be done when it inconveniences users the least.
If a sweep is performed as an exclusive operation on the database, there is additional tuning that the
procedure performs. As long as there are no outstanding active transactions, the sweep updates the state
of data records and the state of the inventory of past transactions. Non-committed transactions are finally
rendered obsolete, and internal data structures need not track them in order to maintain snapshots of
database versions. The benefit of this is a reduction of memory use, and a noticeable performance im-
provement.
We recommend setting cache size at the database level rather than at the server level. This reduces the
likelihood of inappropriate database cache sizes.
Every database on a server requires RAM equal to the cache size (number of database pages) times the
page size. By default, the cache size is 2048 pages per database and the page size is 4KB. Thus, a single
database running at the default setting requires 8MB of memory, but three such databases require 24MB
of memory.
This sets the number of cache pages for the specified database to <n>, overriding the server value, which
by default is 2048 pages.
The default size for a database can also be set using the ALTER DATABASE statement:
To run gfix or ALTER DATABASE, you must be either SYSDBA or the owner of the database.
Both gfix and ALTER DATABASE immediately attempt to expand the cache buffers to the number of pages
requested.
isql -c n database_name
<n> is the number of cache pages to be used as the default for the session; <n> is trimmed to the
database-specific cache setting if it is greater than that value.
A CONNECTstatement entered in an isql query accepts the argument CACHE n. (Refer to the discussion of
CONNECT in the Language Reference manual for a full description of the CONNECT function). For example:
The value <n> can be any positive integer number of database pages. If a database cache already exists
in the server because of another attachment to the database, the cache size is increased only if <n> is
greater than current cache size.
IBX: use the num_buffers parameter to set cache size in the TIBDatabase parameter list. For example:
num_buffers=250. For the parameter to be parsed correctly, there must be no spaces around the = sign.
The number of buffers passed by the InterBase API or IBX is trimmed to the database-specific cache setting
if it is greater than that value.
You can also set the default cache size for each database using the gfix or SET PAGE CACHE utilities.
This approach permits greater flexibility, and reduces the risk that memory is overused, or that database
caches are too small.
We strongly recommend that you use gfix or SET PAGE CACHE to set cache size rather than
DATABASE_CACHE_PAGES.
The empty COMMIT command prompts isql to display information about memory and buffer usage. The
“Buffers” line specifies the size of the cache for that database.
NOTE
The example command listing shows "Buffers = 2048" for user to verify that cache setting has been changed. This is
no longer strictly true. For very large cache buffer settings (>256MB), InterBase incrementally allocates additional cache
buffers on-demand. So it is possible that the listed command will show a Buffers value that is a lower number. The
actual value can always be determined by running gstat -h and examining the Page buffers entry or querying column
RDB$PAGE_CACHE from system table RDB$DATABASE.
If forced writes are not enabled, then even though InterBase performs a write, the data may not be phys-
ically written to disk, since operating systems buffer disk writes. If there is a system failure before the data
is written to disk, then information can be lost.
Performing forced writes ensures data integrity and safety, but slow performance. In particular, operations
that involve data modification are slower.
Forced writes are enabled or disabled in the Database Properties dialog. For more information, refer to
Setting Database Properties.
• Abnormal termination of a database application. This does not affect the integrity of the database.
When an application is canceled, committed data is preserved, and uncommitted changes are rolled
back. If InterBase has already assigned a data page for the uncommitted changes, the page might
be considered an orphan page. Orphan pages are unassigned disk space that should be returned
to free space.
• Write errors in the operating system or hardware. These usually create a problem with database
integrity. Write errors can cause data structures such as database pages and indexes to become
broken or lost. These corrupt data structures can make committed data unrecoverable.
13.1. Validating a Database
You should validate a database:
Database validation requires exclusive access to the database. Shut down a database to acquire exclusive
access. If you do not have exclusive access to the database, you get the error message:
gfix -v
2. If you suspect you have a corrupt database, make a copy of your database using an OS command
(gbak will not back up corrupt data).
3. Use the gfix command to mark corrupt structures in the copied database:
gfix -mend
4. If gfix reports any checksum errors, validate and repair the database again, ignoring any checksum
errors:
NOTE
It may be necessary to validate a database multiple times to correct all the errors.
• Select a disconnected database in the Tree pane and double-click Validation in the Work pane.
• Right-click a disconnected database in the Tree pane and choose Validation from the context menu.
• Select Database|Maintenance|Validation.
1. Check that the database indicated is correct. If it is not, cancel this dialog and re-initiate the Database
Validation dialog under the correct database.
2. Specify which validation options you want by clicking in the right column and choosing True or False
from the drop-down list. See the table below for a description of each option.
3. Click OK if you want to proceed with the validation, otherwise click Cancel.
When IBConsole validates a database, it verifies the integrity of data structures. Specifically, it does the
following:
Option Value
Validate Record Frag- Option values are True and False. By default, database validation reports and releases only page
ments structures. If the Validate Record Fragments option is set to True, validation reports and releas-
es record structures as well as page structures.
Read Only Validation Option values are True and False. By default, validating a database updates it, if necessary. To
prevent updating, set the Read Only Validation option to True.
Ignore Checksum Errors Option values are True and False. A checksum is a page-by-page analysis of data to verify its in-
tegrity. A bad checksum means that a database page has been randomly overwritten (for exam-
ple, due to a system crash).
Checksum errors indicate data corruption. To repair a database that reports checksum er-
rors, set the Ignore Checksum Errors option to True. This enables IBConsole to ignore check-
sums when validating a database. Ignoring checksums allows successful validation of a corrupt
database, but the affected data may be lost.
The errors encountered are summarized in the text display area. The repair options you selected in the
Database Validation dialog are selected in this dialog also.
To repair the database, choose Repair. This fixes problems that cause records to be corrupt and marks
corrupt structures. In subsequent operations (such as backing up), InterBase ignores the marked records.
Some corruptions are too serious for IBConsole to correct. These include corruptions to certain strategic
structures, such as space allocation pages. In addition, IBConsole cannot fix certain checksum errors that
are random by nature and not specifically associated with InterBase.
NOTE
Free pages are no longer reported, and broken records are marked as damaged. Any records marked during repair are
ignored when the database is backed up.
If you suspect you have a corrupt database, perform the following steps:
1. Make a copy of the database using an operating-system command. Do not use the IBConsole Backup
utility or the gbak command, because they cannot back up a database containing corrupt data. If
IBConsole reports any checksum errors, validate and repair the database again, setting the Ignore
Checksum Error option to True. Note: InterBase supports true checksums only for ODS 8 and earlier.
2. It may be necessary to validate a database multiple times to correct all the errors. Validate the
database again, with the Read Only Validation option set to True.
3. Back up the mended database with IBConsole or gbak. At this point, any damaged records are lost,
since they were not included during the back up. For more information about database backup, see
About InterBase backup and restore options
4. Restore the database to rebuild indexes and other database structures. The restored database should
now be free of corruption.
5. To verify that restoring the database fixed the problem, validate the restored database with the Read
Only Validation option set to True.
After a database is shut down, the database owner and SYSDBA are still able to connect to it, but any other
user attempting to connect gets an error message stating that the database is shut down.
14.1.2. Shutdown Options
You can specify shutdown options by selecting a new value from the drop-down list of values. Shutdown
option values include: Deny New Connections While Waiting, Deny New Transactions While Waiting, and
Force Shutdown After Timeout.
This prevents any new processes from connecting to the database during the timeout period. This enables
current users to complete their work, while preventing others from beginning new work.
Suppose the SYSDBA needs to shut down database orders.ib at the end of the day (five hours from now)
to perform routine maintenance. The Marketing department is currently using the database to generate
important sales reports.
In this case, the SYSDBA would shut down orders.ib with the following parameters:
These parameters specify to deny any new database connections and to shut down the database any time
during the next five hours when there are no more active connections.
Any users who are already connected to the database are able to finish processing their sales reports,
but new connections are denied. During the timeout period, the SYSDBA sends out periodic broadcast
messages asking users to finish their work by 6 p.m.
When all users have disconnected, the database is shut down. If all users have not disconnected after five
hours, then the database is not shut down. Because the shutdown is not critical, it is not forced.
It would be inappropriate to deny new transactions, since generating a report could require several trans-
actions, and a user might be disconnected from the database before completing all necessary transactions.
It would also be inappropriate to force shutdown, since it might cause users to lose work.
This is the most restrictive shutdown option, since it prevents any new transactions from starting against
the database. This option also prevents any new connections to the database.
Suppose the SYSDBA needs to perform critical operations that require shutdown of the database orders.ib.
This is a database used by dozens of customer service representatives throughout the day to enter new
orders and query existing orders.
At 5 p.m., the SYSDBA initiates a database shutdown of orders.ib with the following parameters:
These parameters deny new transactions for the next hour. During that time, users can complete their
current transactions before losing access to the database. Simply denying new connections would not be
sufficient, since the shutdown cannot afford to wait for users to disconnect from the database.
During this hour, the SYSDBA sends out periodic broadcast messages warning users that shutdown is
happening at 6 p.m and instructs them to complete their work. When all transactions have been completed,
the database is shut down.
After an hour, if there are still any active transactions, IBConsole cancels the shutdown. Since the SYSDBA
needs to perform database maintenance, and has sent out numerous warnings that a shutdown is about
to occur, there is no choice but to force a shutdown.
If critical database maintenance requires a database to be shut down while there are still active transactions,
the SYSDBA can force shut down. This step should be taken only if broadcast messages have been sent
out to users that shutdown is about to occur. If users have not heeded repeated warnings and remain
active, then their work is rolled back.
This option does not deny new transactions or connections during the time-out period. If, at any time
during the time-out period, there are no connections to the database, IBConsole shuts down the database.
IMPORTANT
Forcing database shutdown interferes with normal database operations, and should only be used after users have been
given appropriate broadcast notification well in advance.
14.2. Restarting a Database
After a database is shut down, it must be restarted (brought back online) before users can access it.
To restart a database, select a previously shut down database from the Tree pane and choose Database|
Maintenance|Database Restart or double-click Database Restart in the Work pane. The currently selected
database is brought back online immediately.
15. Limbo Transactions
When committing a transaction that spans multiple databases, InterBase automatically performs a two-
phase commit. A two-phase commit guarantees that the transaction updates either all of the databases
involved or none of them – data is never partially updated.
NOTE
The Borland Database Engine (BDE), as of version 4.5, does not exercise the two-phase commit or distributed transac-
tions capabilities of InterBase, therefore applications using the BDE never create limbo transactions.
In the first phase of a two-phase commit, InterBase prepares each database for the commit by writing
the changes from each subtransaction to the database. A subtransaction is the part of a multi-database
transaction that involves only one database. In the second phase, InterBase marks each subtransaction as
committed in the order that it was prepared.
If a two-phase commit fails during the second phase, some subtransactions are committed and others are
not. A two-phase commit can fail if a network interruption or disk crash makes one or more databases
unavailable. Failure of a two-phase commit causes limbo transactions, transactions that the server does
not know whether to commit or roll back.
It is possible that some records in a database are inaccessible due to their association with a transaction
that is in a limbo state. To correct this, you must recover the transaction using IBConsole. Recovering a
limbo transaction means committing it or rolling it back. Use gfix to recover transactions.
15.1. Recovering Transactions
You can recover transactions by any of the following methods:
• Select a connected database in the Tree pane and double-click Transaction Recovery in the Work
pane or choose Database|Maintenance|Transaction Recovery.
• Right-click a connected database in the Tree pane and choose Maintenance|Transaction Recovery
from the context menu.
The Transaction Recovery dialog contains two tabs, Transactions and Details. The Transactions tab displays
a list of limbo transactions that can then be recovered—that is, to committed or rolled back. You can also
seek suggested recovery actions and set current actions to perform on the selected limbo transactions.
The Details tab displays detailed information about a selected transaction.
15.1.1. Transaction Tab
All the pending transactions in the database are listed in the text area of the Transactions tab. You can roll
back, commit, or perform a two-phase commit on such transactions.
The information on the path to the database was stored when the client application attempted the commit.
It is possible that the path and network protocol from that machine does not work from the client which
is now running IBConsole. Before attempting to roll back or commit any transaction, confirm the path of
all involved databases is correct.
When entering the current path, be sure to include the server name and separator indicating communi-
cation protocol. To use TCP/IP, separate the server and directory path with a colon (:). To use NetBEUI,
precede the server name with either a double backslash (\\) or a double slash (//), and then separate the
server name and directory path with either a backslash or a slash.
3. If you want to continue with the transaction recovery process select a repair option and click Repair,
otherwise click Cancel. To determine the recommended action, click on the transaction and select the
Details tab. For further information about transaction recovery suggestions, see Details Tab below.
15.1.2. Details Tab
The Details tab displays the host server, the remote server, database path, and recommended action: either
commit or rollback. If you want to continue with the transaction recovery process select a repair option
and click Repair, otherwise click Cancel.
• Select a server (or any branch under the server hierarchy) in the Tree pane and choose Server|View
Logfile.
• Right-click the desired server in the Tree pane and choose View Logfile from the context menu.
• Under the desired server, select Server Log in the Tree pane and then double-click View Logfile in
the Work pane.
The standard text display window enables you to search for specific text, save the text to a file, and print
the text. For an explanation of how to use the standard text display window, see Text Viewer Window.
• Database shutdown
• Changing database mode to read-only or read-write
• Changing the dialect of a database
• Setting cache size at the database level
• Committing limbo transactions
• Mending databases and making minor data repairs
• Sweeping databases
• Displaying, committing, or recovering limbo transactions
To run gfix, you must attach as either SYSDBA or the owner of the database. Most of these actions can
also be performed through IBConsole.
Options: In the OPTION column of the following table, only the characters outside the brackets ([ ]) are
required. You can specify additional characters up to and including the full option name. To help identify
options that perform similar functions, the TASK column indicates the type of activity associated with an
option.
gfix Options
Option Task Description
-ac[tivate] Activate Activate shadows when the database dies. NOTE: syntax is
shadows gfix -ac (no database name).
-at[tach] n Shutdown Used with -shut to prevent new database connections
during timeout period of <n> seconds; shutdown is can-
celed if there are still processes connected after <n> sec-
onds.
-b[uffers] n Cache buffers Sets default cache buffers for the database to <n> pages.
-c[ommit] {ID|all} Transaction Commits limbo transaction specified by ID or commit all
recovery limbo transactions.
-force n Shutdown Used with -shut to force shutdown of a database after
<n> seconds; this is a drastic solution that should be used
with caution.
-fu[ll] Data repair Used with -v to check record and page structures, releas-
ing unassigned record fragments.
-h[ousekeeping] n Sweeping Changes automatic sweep threshold to <n> transactions.
gfix Options
Option Task Description
-pa[ssword] text Remote ac- Checks for password <text> before accessing a database.
cess
-pr[ompt] Transaction Used with -l to prompt for action during transaction re-
recovery covery.
-r[ollback] {ID| all} Transaction Rolls back limbo transaction specified by ID or roll back all
recovery limbo transactions.
-sh[ut] Shutdown
• Shuts down the database.
• Must be used in conjunction with -attach, -force, or -
tran.
-sq[l_dialect]n Database di- Changes database dialect to <n>.
alect
• Dialect 1 = InterBase 5.x compatibility
• Dialect 3 = Current InterBase with SQL92 features
-sw[eep] Sweeping Forces an immediate sweep of the database.
Examples: The following example changes the dialect of the customer.ib database to 3:
1. Make sure you work with a copy of the database, this can prevent further damage and provides
exclusive access to the database, which is necessary for performing the required actions.
2. Type gfix -v -f databasename.gdb on the command line console.
3. If the previous step reports corruption, type gfix -m -i databasename.gdb
A database backup saves a database to a file on a hard disk or other storage medium. InterBase provides
full and incremental backup capability, as well a number of options that allow you to tailor your backups
to suit a iety of scenarios.
To most effectively protect your database from power failure, disk crashes, or other potential data loss,
perform backups on a regular basis. For additional safety, store the backup file in a different physical
location from the database server.
This chapter explains how to perform full and incremental backups on InterBase machines. It also explains
how to restore InterBase databases.
InterBase backups can run concurrently while other users are using the database. You do not have to
shut down the database to run a backup. However, any data changes that clients commit to the database
after the backup begins are not recorded in the backup file.
Use the InterBase gbak command to specify and execute backup and restore operations from a Windows
or Unix command line. Familiarity with isql, InterBase version of SQL is recommended. isql provides a
number of options to help tailor your backup and restore to suit different circumstances and environments.
• The IBConsole
The IBConsole intuitive user interface allows you to use your mouse, context menus, and dialog boxes to
specify the type of backup and restore you want to perform. The same backup and restore options that
are available using gbak are available through the IBConsole user interface. You do not need to be familiar
with command-line operations or with SQL or isql to use IBConsole.
This chapter explains how to use both tools to perform backups and restores.
• Logical:
The full backup typically performed by gbak is a “logical” backup. It extracts every record in the database
and stores it in a different format. Thus, it is not an exact replica of the database file. Logical backups
reclaim space occupied by deleted records, thereby reducing database size.
A logical backup, performed by a gbak client, can save the target backup file anywhere on the network;
you do not have to have an InterBase server on the client machine. If the backup is performed using the
Services API, then the backup file can only be written to file systems that are accessible to the server (since
the server is performing the backup operation).
When executing a logical backup with gbak, use the following syntax:
If you choose the Backup option using IBConsole, this is the type of backup InterBase executes.
Restoring from logical backups gives you the option of changing the database page size and distributing
the database among multiple files or disks.
• Physical:
InterBase physical backup, also referred to as an online dump, copies the database at the page level and
saves it in its original format. Thus, a physical backup creates an exact replica of the database during backup
process. You can convert the replica to a read-write database, though if you do so, you will no longer be
able to dump to the replica from the original database.
Notice that the physical backup uses the -d switch rather than the -b switch that is specified in the logical
backup.
An incremental backup copies all of the changes that have been committed to the database since the
last full backup. An incremental backup is a physical backup and uses the -d switch. The first time you use
the gbak -d switch, InterBase performs a full physical backup (an online dump). After the initial full dump,
each subsequent backup using the -d switch performs an incremental backup, saving and copying all of
the transactions committed since the last full backup.
If you choose the Incremental Backup option using IBConsole, IBConsole performs an initial full online
dump using the -d switch. All subsequent backups using the -d switch are incremental.
IMPORTANT
To add an additional level of database protection, use journal files and journal archiving. Journal files record each
database transaction as it occurs, even those that occur when a backup is running. A journal archive stores current journal
files. You can use a journal archive to recover data to a specific point in time. For more information about journaling
and journal archives, see Journaling and Disaster Recovery
1.3. Database ownership
Although backing up a database can be performed only by the owner or SYSDBA, any user can restore
a database as long as they are not restoring it over an existing database. A database file restored from a
logical backup belongs to the user ID of the person who performed the restore. This means that backing
up and restoring a database is a mechanism for changing the ownership of a database. It also means that
an unauthorized user can steal a database by restoring a backup file to a machine where he knows the
SYSDBA password. It is important to ensure that your backup files are secured from unauthorized access.
To restore a database over an existing database, you must be SYSDBA or the owner of the existing database.
1. Before installing a new version of InterBase, back up databases using the old version.
2. Install the InterBase server.
3. Once the new server is installed, restore the databases.
For more information about migrating to a later version of InterBase, see Migrating to InterBase.
NOTE
For information on how to use the gbak command to encrypt backup files and to restore encrypted backup files, see
Encrypting Your Data.
• Unless the -service option is specified, gbak writes the backup files to the current directory of the
machine on which it is running, not on the server where the database resides. If you specify a location
for the backup file, it is relative to the machine where gbak is executing. You can write the backup files
only to this local machine or to drives that are mapped to it. Note that the -service switch changes
this behavior. (See Using gbak with InterBase Service Manager.)
• When you are backing up a multifile database, specify only the first file in the backup command. You
must not name the subsequent database files: they will be interpreted as backup file names.
• The default unit for backup files is bytes. You can choose to specify kilobytes, megabytes, or gigabytes
(k, m, or g) instead. Restored database files can be specified only in database pages.
• Use the -transportable switch if you operate in a multiplatform environment. This switch permits the
database to be restored to a platform other than the one on which it originally resided. Using this
option routinely is a good idea when you are operating in a multiplatform environment.
• Use the -service switch if you are backing up to the same server that holds the original database. This
option invokes the InterBase Service Manager on the server host and saves both time and network
traffic.
TIP
It is good security practice to change your backup files to read-only at the system level after creating them. This prevents
them from being accidentally overwritten. In addition, you can protect your databases from being “kidnapped” on UNIX
and Windows systems by placing the backup files in directories with restricted access.
On UNIX, can also be stdout, in which case gbak writes its output to the standard output (usually a pipe).
No size need be specified when restoring to a single file, since the database always expands as needed to
fill all available space.
<size> Length of a backup file or restored database file
The only permissible unit for a restored database file is database pages; minimum value is 200.
Options: In the OPTION column of the following tables, only the characters outside the square brackets
([ ]) are required.
The following table lists the options to gbak that are available for creating backups.
IMPORTANT NOTE: If you are providing file path names with embedded spaces in
them and using the InterBase service manager (-service switch in GBAK), you will need
to multi-quote the file names:
<double_quote><single_quote>filepath<single_quote> <double_quote>
The above is required because the command shell strips away the external dou-
ble_quotes and only leaves the internal single_quotes for InterBase to know that it is a
single string value.
For example:
• Performing an incremental online dump still requires a full scan of the source database.
• The performance improvement accrues from limiting the number of page writes to the online dump
files, especially if those files are located on a remote file server.
• Multiple online dumps of the same or distinct databases can be run concurrently though this would
not be recommended for performance reasons.
• An active online dump can be cancelled by the InterBase Performance Monitor or killing the GBAK
process.
• External tables are not backed up by an online dump.
• External tables may not be accessible if the online dump is attached as a read-only database. If the
external file pathnames cannot be accessed from the online dump location, there is no way to modify
the metadata of the dump without making the dump a read-write database. If it is made a read-write
database, it can no longer be a target for online dump again.
• Since an online dump is a physical backup, the online dump files are not transportable to other hard-
ware platforms. To make the backup transportable, use traditional logical backup of gbak using the
-t switch.
• When a CREATE JOURNAL ARCHIVE statement is executed, InterBase uses the online dump feature to
copy the database to a journal archive directory. For more information about journal files and journal
archiving, see Journaling and Disaster Recovery
GBAK {-D} dbname file [size] add_file1 [size1] add_file2 [size2] ...
The first dump file in the list is similar to the first database file in a multi-file database. It is the file that
is used as a reference to an existing online dump. If there are additional dump files listed on the GBAK
command line, those files are added to the set of files in the online dump.
Example: The following example can assist you in creating an initial incremental online dump.
In the example above, EMPLOYEE.gdmp.1 was added in the course of a full database dump.
Re-executing the command gives an error because it tries to add EMPLOYEE.gdmp.1 again causing a file
creation error. The last command adds a new file EMPLOYEE.gdmp.2 successfully.
The online dump files can be on either a local or a remote file system that is writable by the InterBase
server. An online dump is a server-side operation only. While the online dump files can be located on
any mounted file system, the page appendix file is always on the local file system. This file is written to by
concurrent server threads handling client requests when it is necessary to preserve the state of an image
of a page for the online dump. This is analogous to InterBase multigenerational architecture (MGA) where
a previous version of a row is stored when updating a row to preserve a snapshot of a transaction. The
page appendix file helps to maintain the physical page snapshot of the online dump. It is a temporary file
and is deleted when the online dump completes.
The [size] parameter is optional and denotes the size of the file in units of pages, using the page size of
the database. If the [size] parameter is not provided then that dump file's size will be determined by its
file-sequenced counterpart in the database. If the sequence of the dump file is higher than the sequence
of any database file, then it takes the size of its predecessor dump file.
If you run GBAK -D against an existing online dump, an incremental dump will be created.
This updates the online dump with only those pages that have changed since the last dump. An incremental
dump can always be retried if it fails. If a full online dump fails, InterBase will delete the online dump files
that were written prior to the failure. If InterBase cannot access those files because of the failure, those
online dump files will have to be deleted manually.
Distinguished Dump: "Incremental Dump" before and in InterBase XE3 required the database server
to read all pages from the database file, but only write the pages that had been modified to the target
database dump file. With the implementation of a tracking system in XE7, only those pages that need
updating since the last dump would be fetched. This provides instantaneous updates to the target. There
can only be 1 "Distinguished Dump" per source database. The choice of a "distinguished dump" is as follows:
• The first "dump" on the source database file will be a "distinguished dump"; all further dump targets
are "normal dump" targets.
• Should the "first" dump be made online and thus sever its link to the source database, the next "dump"
to be incrementally updated will now become the "disinguished dump".
The online dump files are marked as a read-only InterBase database. This means that it can be accessed by
read-only database applications. It is undefined how such database applications will behave if they access
the online dump “database” while the dump files are being incrementally updated. If an online dump is
converted to read-write, it ceases to be an online dump and becomes a standalone database. Attempting
to perform an online dump against it will fail.
The online dump can be converted to a read-write database by using the gfix -mode read_write command
and used in place. If the current location is not convenient for database processing, then online dump can
be run against these dump files to copy them somewhere else local or remote. This provides a general
copy mechanism that allows multifile databases to be copied and have their internal secondary file name
links automatically updated for the copy destination.
Database validation (gfix -v)can be run against an online dump because it is a database. An additional
validation check is performed against an online dump, which checks that no database page has a write
timestamp greater than that of the online dump timestamp. The online dump timestamp represents that
last time a full or incremental dump succeeded.
2.3.4. Timestamp Changes
GSTAT -H has been modified to list the online dump timestamp after the database creation date entry.
Note that the database creation date is that of the source database and not the online dump.
You can request an online dump by passing a string of database parameter blocks to the isc_at-
tach_database() API.
A successful online dump returns a warning status vector to pass back dump information status:
For very large databases with intensive update activity, the page appendix file could also grow to a very
large size. There must be adequate space in the temp directories to handle this storage demand or the
online dump will fail. The dump information returned to GBAK about the number of pages written to the
appendix file can aid configuration of the temp file space.
Example:
/D/testbed>isql
Use CONNECT or CREATE DATABASE to specify a database
SQL> create database 'pr.ib' preallocate 500;
SQL> commit;
SQL> quit;
/D/testbed>ls -l pr.ib
-rwxrwxrwx 1 Administrators None 2048000 Jul 2 18:09
pr.ib /* It is 2MB size because each of the 500 database pages is
4KB in size */
/D/testbed>isql -a pr.ib
SET SQL DIALECT 3;
/* CREATE DATABASE 'pr.ib' PREALLOCATE 500
PAGE_SIZE 4096
*/
/* Grant permissions for this database */
/D/testbed>isql -x pr.ib
SET SQL DIALECT 3;
A GBAK preallocate switch value of 0 (zero) effectively disables database preallocation in the backup file or
restored database. In GBAK verbose mode, database preallocation is logged to the console. The example
below shows a sample database backup in verbose mode. A similar message is logged for database restore.
Example:
If a database restore reduces the page size, the number of pages for database preallocation is automatically
scaled upward to maintain a constant database preallocation size in bytes. If the restored page size is
increased, database preallocation is reduced accordingly with a similar “Reducing” message written to
the console. If the GBAK -PREALLOCATEswitch was given, then the automatic scaling of the database
preallocation does not occur with changing page size. In other words, the -PREALLOCATE switch takes
precedence.
Example:
For restoring:
By extension, you can restore from multiple files to multiple files using the following syntax:
The USER and PASSWORD server credentials are required to create a database on the server and execute
the restore service. The -eua_u[ser] name and -eua_p[assword] text database credentials are required
to ensure that only the database owner can restore an EUA database.
On UNIX, this can also be stdin, in which case gbak reads input from the standard input (usually a pipe).
<dbfile> The name of a restored database file.
<size> Length of a backup file or restored database file
• The only permissible unit for a restored database file is database pages; minimum value is 200.
• Default unit for a backup file is bytes.
• Size of backup files can also be specified in kilobytes, megabytes, or gigabytes.
• Do not specify a size for the final backup file or database file; the last file always expands as needed to
fill all available space.
The following table lists gbak options that are available when restoring databases.
Either EUA switch can be omitted if it has an identical value to its counterpart. However
it is recommended that the PASSWORD and EUA_PASSWORD should not be the same.
-eua_p[assword] text Checks for password text before accessing EUA (embedded user authentication)
database.
The -user and -password options still need to be provided, in addition to your -eua
equivalents when restoring an EUA database.
Either EUA switch can be omitted if it has an identical value to its counterpart. However
it is recommended that the PASSWORD and EUA_PASSWORD should not be the same.
-k[ill] Does not create any shadows that were previously defined.
-mo[de] {read_write | read_only} Specifies whether the restored database is writable
TCP/IP hostname:service_mgr
Named pipes \\hostname\service_mgr
Local service_mgr
-user name Checks for user <name> before accessing database.
-use_[all_space] Restores database with 100% fill ratio on every data page. By default, space is reserved
for each row on a data page to accommodate a back version of an UPDATE or DELETE.
Depending on the size of the compressed rows, that could translate e to any percent-
age.
-v[erbose] Shows what gbak is doing.
-va[lidate] Use to validate the database when restoring it.
-w[rite] {async | sync | direct} Overrides a database write mode. The “write” mode is preserved during a backup/re-
store lifecycle.
sync enables forced writes; async enables buffered writes; direct enables direct I/O.
-y [file | suppress_output] If used with -v, directs status messages to <file>; if used without -v and <file> is omit-
ted, suppresses output messages.
-z Show version of gbak and of InterBase engine.
• Anyone can restore a database. However, only the database owner or SYSDBA can restore a database
over an existing database.
• Do not restore a backup over a database that is currently in use; it is likely to corrupt the database.
• When restoring from a multifile backup, name all the backup files, in any order.
• Do not provide a file size for the last (or only) file of the restored database. InterBase does not return
an error, but it always “grows” the last file as needed until all available space is used. This dynamic
sizing is a feature of InterBase.
• You specify the size of a restored database in database pages. The default size for database files
is 200 pages. The default database page size is 4K, so if the page size has not been changed, the
default database size is 800K. This is sufficient for only a very small database. To change the size of
the database pages, use the -p[age_size] option when restoring.
TIP
Use the -service switch if you are restoring to the same server that holds the backup file. This option invokes the
InterBase Service Manager on the server host and saves both time and network traffic.
NOTE
If you specify several target database files but have only a small amount of data, the target files are quite small (around
800K for the first one and 4K for subsequent ones) when they are first created. They grow in sequence to the specified
sizes as you populate the database.
2.4.1. Backup/Restore Tablespaces
Backup, restore and recovery services are enhanced to support tablespaces. This document describes the
functional specification of new capabilities provided by the GBAK command-line tool as manifested a new
switch. It also covers the behavioral effects of the new switch, which is quite different from the behavior of
a full database backup, restore or recovery. It is assumed that this switch and functionality are accessible
through InterBase's services management facility.
A database can now be organized as a collection of tablespaces, which can contain a user-specified set
of tables and indexes. In a related manner, individual tablepaces can be backed up and restored. A con-
sequence of this flexibility is that data restored from individual tablespace backups may be from a different
point in time than data in other tablespaces because of different transaction snapshots used to perform
the backup. Therefore, it requires careful planning with respect to tablespace content and referential and
integrity constraints, which may cross tablespace boundaries.
2.4.1.1. User interface/Usability
The gbak command-line tool introduces the {+|-} tablespace switch for specifying one or more named
tablespaces. When this switch is not present, gbak will backup, restore or recover all tablespaces comprising
the full database. Full database restoration or recovery of a database can only occur if the backup file
was created with no tablespace switches. Such a backup file is called a database backup and includes all
metadata and user data for the database. If a tablespace switch is given then the backup file is called a
tablespace backup and only includes user data for the tables contained by the tablespace; It does not
include any metadata except for what is needed to restore the tables contained by the tablespace backup
file. A tablespace backup can include multiple named tablespaces.
In the case of restoring the PRIMARY tablespace from a tablespace backup, the primary tablespace file is
not written over as doing so would destroy the database metadata. Instead, the user tables are truncated
and then the data from the backup file is inserted. This is the behavior for a logical database or tablespace
backup.
When individual tablespaces are restored either -c(reate) or -r(estore) must also be specified. The -c
switch provides a "soft" restore of user tables, by performing a TRUNCATE operation the table. This allows
tables and indices that are created after the backup file is made to be preserved. The -r switch deletes
the tablespace files at the file system level and recreates the files at the same or different location. If the
existing file has been corrupted, the -r switch may be the only choice.
The + or - switch designator is used to include or exclude one or more tablespaces from the tablespace
backup.
As an example, assume the InterBase Employee database is stored at /databases/employee.idb It is com-
posed of the default PRIMARY tablespace, the HR tablespace stored at /tablespaces/hr.its, and the EMPLOYEE
tablespace stored at /tablespaces/employee.its. Here are some gbak command examples:
The following two examples show that full database backup and restore operate as usual:
This example shows that individual tablespaces can be extracted from a full database backup.
Tablespace backup files are created when the tablespace switch is used.
or equivalently:
The -tablespace switch can be use to exclude individual tablespaces when using the +tablespace switch
would be too lengthy or risk excluding new tablespaces in the future if the gbak command was not updated.
To restore individual tablespaces from a database or tablespace file use the -create_tablespace and -
replace_tablespace switches. The -create_tablespace does not raise an error if the tablespace file already
exists and does not delete an existing tablespace file. Instead it performs a TRUNCATE TABLE command on
every table contained by the given tablespaces. It then restores the tables contained by each tablespace
from the backup file. This preserves tables that were created after the backup was made.
If the existing tablespace files are corrupt the TRUNCATE TABLE command cannot be performed then it may
be necessary to delete the existing files and create new files by using the -replace_tablespace switch.
NOTE
The trailing suffix "_tablespace" for these switches must specify at least the "_tablesp" substring to be recognized.
Backup files are either "database backup file" (where all schema information is stored in addition to the
data) or "tablespace backup file" (where only data is stored for the selected tablespaces). You can use gbak
to get a listing of metadata information from the backup file, by using the following command.
Full and incremental online dump as well as distinguished dump are supported. The first file after the
database file is the primary dump file. Its contents include the database metadata, the PRIMARY tablespace
and all other secondary tablespaces that did not designate a separate file in their tablespace definition.
It is a constraint of online dump that all secondary tablespaces allocated to a file must be included in the
gbak dump command line. It is an error to omit a tablespace or to name a tablespace name more than
once. Each output file name must be unique among the file names given in the command
2.4.1.2. Services API
There are five new service parameters for use with the Services API:
• isc_spb_res_create_tablespace
• isc_spb_res_replace_tablespace
• isc_spb_tablespace_include
• isc_spb_tablespace_exclude
• isc_spb_tablespace_file
These are used as arguments to the Services API database backup/restore actions: isc_action_svc_backup
and isc_action_svc_restore. The first two parameters are bit flag format and passed by OR'ing them with
other bit flag parameters before passing them as an argument to isc_spb_options. They generate the -
create_tablespace and -replace_tablespace switches, respectively.
For using the service API to dump a database with tablespaces, follow your isc_spb_dmp_file definition
with a list of tablespaces each with their name after isc_spb_tablespace_include followed by destination
path after isc_spb_tablespace_file.
and network traffic when you want to create the backup on the same host on which the database resides.
When the Service API is used, both the database and the backup file must be accessible to the server.
When you use the -service switch, you specify the host name followed by the string “service_mgr”. The
syntax you use for this ies with the network protocol you are using. Together, these components are
referred to as “host_service” in the syntax statements that follow in this section:
NetBEUI \\hostname\service_mgr
Local service_mgr
The syntax in the right column appears in the gbak syntax below as “host_service”.
The local case is trivial on NT. If you are backing up a local database, the results in terms of time and
network traffic are the same whether you use the -service switch or not, even though the actual imple-
mentation would be slightly different. On UNIX systems, the local case is equivalent to specifying (for TCP/
IP) localhost:service_mgr and saves both time and network traffic.
You can back up to multiple files and restore from multiple files using Service Manager.
IMPORTANT
On UNIX systems, in order to restore a database that has been backed up using the Service Manager, you must either
use the Service Manager for the restore or you must be logged onto the system as the user that InterBase was running
as when the backup was created (either root or InterBase). This is because the InterBase user (root or InterBase)
is the owner of the backup file at the system level when the Service Manager is invoked, and the backup file is readable
to only that user. When gbak is used to back up a database without the -service option, the owner of the backup
file at the system level is the login of the person who ran gbak. On Windows platforms, the system-level constraints
do not apply.
• The -user that is specified, with a correct password, as part of the gbak command.
• The user and password specified in the ISC_USER and ISC_PASSWORD environment variables, pro-
vided they also exist in the InterBase security database. (Setting these environment variables is strongly
not recommended, since it is extremely insecure.)
• UNIX only: If no user is specified at any of the previous levels, InterBase uses the UNIX login if the user
is running on the server or on a trusted host.
The following examples use forward slashes exclusively. InterBase accepts either forward or backward slashes for paths
on Wintel platforms.
The next example backs up foo.ib, which resides on the server jupiter and writes the backup file to the
C:/archive directory on the client machine where gbak is running. As before, foo.ib can be a single file
database or the name of the first file in a multifile database. This syntax causes the same amount of network
traffic as the first example.
The next example backs up the same database on jupiter, but uses the -se[rvice] switch to invoke the
Service Manager on jupiter, which writes the backup to the \backup directory on jupiter. This command
causes very little network traffic and is therefore faster than performing the same task without the -se (-
service) switch. Note that the syntax (jupiter:service_mgr) indicates a TCP/IP connection.
The next example again backs up foo1.ib on server jupiter to multiple files in the /backup directory on
jupiter using the Service Manager. This syntax backs up a single file or multifile database and uses a
minimum of time and network traffic. It converts external files as internal tables and creates a backup in
a transportable format that can be restored on any InterBase-supported platform. To back up a multifile
database, name only the first file in the backup command. In this example, the first two backup files are
limited to 500K. The last one expands as necessary.
The next example restores a multifile database from the /backup directory of jupiter to the /companydb
directory of jupiter. This command runs on the server by invoking Service Manager, thus saving time and
network traffic. In this example, the first two files of the restored database are 500 pages long and the
last file grows as needed.
The next example executes on server Jupiter using Service Manager and restores a backup that is on Jupiter
to another server called Pluto.
/backup/foo.ibk pluto:/companydb/foo.ib
1. Right-click on a database in the tree pane, and select Backup/Restore from the context menu.
2. When the context menu expands to display backup and restore options, select Backup. The
Database Backup dialog appears, as shown in the figure:
3. Check the database server to make sure the indicated server is correct. If it is not, cancel this dialog
and re-initiate the Database Backup dialog under the correct server.
4. If you accessed the Database Backup dialog from a database alias, the Alias field is automatically
assigned. If you accessed the Database Backup dialog from the Databases menu, then you must
select an alias from the list of database aliases.
The database alias references the associated database file name, so you need to specify only the alias
name, not the actual database filename, when indicating the database to back up. If the database spans
multiple files, the server uses the header page of each file to locate additional files, so the entire database
can be backed up based on the alias filename.
5. Select a destination server from a list of registered servers in the Backup Files Server drop‑down list.
6. Once a destination server has been selected, a list of backup file aliases is available from the Backup
Files Alias drop‑down list. If you want to overwrite an existing backup file, select the appropriate file
from the drop‑down list. If you want to create a new backup file, you can type a new alias name in
the Backup File(s) Alias field.
7. On the File Name section, click to set the name and destination folder of your backup.
8. On the Tablespaces the Include field lists all the tablespaces included in the backup. If you want
to exclude a tablespace from the backup process, select it and click the right arrow to add it to
the Excluded list.
• To use multiple files, go to the Multiple Files tab and select Use Multiple Files then click to
add files.
9. You can specify backup options by entering a valid value, by clicking the option value and choosing
a new value from a drop‑down list of values, or by double-clicking the option value to rotate its
value to the next in the list of values. See About IBConsole backup options below for descriptions
of these options.
NOTE
Database files and backup files can have any name that is legal on the operating system; the gdb and gbk file extensions
are InterBase conventions only. Because files that have the gdb extension automatically get backed up whenever they
are touched in some versions of Windows XP, InterBase now recommends using an ib extension for database files and
ibk for backup files.
A backup file typically occupies less space than the source database because it includes only the current
version of data and incurs less overhead for data storage. A backup file also contains only the index
definition, not the index data structures.
If you specify a backup file that already exists, IBConsole overwrites it. To avoid overwriting, specify a unique
name for the backup file.
3.1.2. Format
Option values are Transportable and Non-transportable.
To move a database to a machine with an operating system different from the one under which the backup
was performed, make sure the Format option is set to Transportable. This option writes data in a generic
format, enabling you to move to any machine that supports InterBase.
IMPORTANT
Never copy a database from one location to another. Back it up and then restore it to the new location.
3.1.3. Metadata Only
Option values are True and False.
When backing up a database, you can exclude its data, saving only its metadata. You might want to do
this to:
To back up metadata only, select True for the Metadata Only option.
TIP
You can also extract a database’s metadata using isql. isql produces a SQL data definition text file that contains the
SQL code used to create it. IBConsole backup Metadata Only creates a binary backup file containing only metadata.
3.1.4. Garbage Collection
Option values are True and False.
By default, IBConsole performs garbage collection during backup. To prevent garbage collection during a
backup, set the Garbage Collection option value to False.
Garbage Collection marks space used by old versions of data records as free for reuse. Generally, you
want IBConsole to perform garbage collection during backup.
TIP
Disabling garbage collection during the backup process improves backup performance. If garbage collection is neces-
sary, you can run a separate sweep operation using gfix. In addition, you do not want to perform garbage collection
if there is data corruption in old record versions and you want to prevent InterBase from visiting those records during
a backup.
3.1.5. Transactions in limbo
Option values are Process and Ignore.
To ignore limbo transactions during backup, set the Transactions in Limbo option value to Ignore.
When IBConsole ignores limbo transactions during backup, it ignores all record versions created by any
limbo transaction, finds the most recently committed version of a record, and backs up that version.
Limbo transactions are usually caused by the failure of a two-phase commit. They can also exist due to
system failure or when a single-database transaction is prepared.
Before backing up a database that contains limbo transactions, it is a good idea to perform transaction
recovery, by choosing Database>Maintenance>Transaction Recovery in the Database Maintenance
window. Refer to Recovering Transactions for more information.
3.1.6. Checksums
NOTE
For performance reasons, InterBase supports true checksums only for ODS 8 and earlier. For ODS 9 and later, InterBase
always generates the string “12345” as the checksum. This maintains compatibility with older versions.
To ignore checksums during backup, set the Checksums option value to Ignore.
A checksum is a page-by-page analysis of data to verify its integrity. A bad checksum means that a data
page has been randomly overwritten; for example, due to a system crash.
Checksum errors indicate data corruption, and InterBase normally prevents you from backing up a
database if bad checksums are detected. Examine the data the next time you restore the database.
3.1.7. Convert to Tables
To convert external files to internal tables, set the Convert to Tables option value to True.
To monitor the backup process as it runs, set the Verbose Output option value to To Screen. This option
opens a standard text display window to display status messages during the backup. For example:
The standard text display window enables you to search for specific text, save the text to a file, and print
the text. For an explanation of how to use the standard text display window, see Text Viewer Window.
1. In the tree pane, right-click the database on which to perform an incremental backup, and select
Backup/Restore from the context menu.
2. When the context menu expands to display backup and restore options, select Incremental Backup.
The Incremental Backup dialog appears, as shown in the figure:
• To add a dump file click on the Files section, on the New Dump File dialog click to set the
name and destination folder of your backup.
• Once you add a file, the Tablespaces tab shows a list of tablespaces on the database.
• To change a file location, select a file and click
4. To use multiple files go the Multiple Files tab, select Use Multiple Files and click to add files.
5. To overwrite the previous incremental backup, change the Overwrite value to True. For detailed
information about what occurs when you overwrite an incremental backup, see Over-writing Incre-
mental backups
6. Choose OK to start the backup.
IMPORTANT
To restore a database:
1. Check the source Backup File(s) Server to make sure the indicated server is correct. If it is not, cancel
this dialog and re-initiate the Database Restore dialog under the correct server.
2. If you accessed the Database Restore dialog from a backup alias, then the Alias field is automatically
assigned.
3. If you accessed the Database Restore dialog from Backup, then you must select an alias from the
list of backup aliases or click to add backup files. It is important that you include all filenames
associated with the restore.
NOTE
The backup alias references the associated backup file names, so you need only to specify the alias name, not the actual
backup file name, when indicating the backup to restore. If the backup spans multiple files, the server uses the header
page of each file to locate additional files, so the entire backup can be restored based on the alias filename.
4. Once you select your backup file(s) the table on the Tablespace Info tab populates with all the
tablespaces present on the backup. On this section you can choose which tablespaces include in the
restore process.
5. Select a destination server from a list of registered servers in the Database Server drop‑down list.
6. If you want to restore to an existing database, select its alias from the Database Alias drop-down
list. If you want to restore to a new database, type a new alias name in the Database Alias field and
click to set a filename and destination.
7. To use multiple files, select Use Multiple Files and click to add files.
NOTE
1. You can specify options for the restore by entering a valid value, by clicking the option value and
choosing a new value from a drop‑down list of values or by double-clicking the option value to rotate
its value to the next in the list of values. See Restore options below for a description of these options.
2. Click OK to start the restore.
Typically, a restored database occupies less disk space than it did before being backed up, but disk space
requirements could change if the ODS version changes. For information about the ODS, see Restoring
the ODS.
NOTE
The InterBase restore utility allows you to restore a database successfully even if for some reason the restore process
could not rebuild indexes for the database. For example, this can occur if there is not enough temporary disk space to
perform the sorting necessary to build an index. If this occurs, the database is restored and available, but indexes are
inactive. After the restore completes, use ALTER INDEX to make the indexes active.
4.1. Restore options
The restore options are shown on the right side of the Database Restore dialog. You can specify options
by entering a value, by clicking the option value and choosing a new value from a drop‑down list of values,
or by double-clicking the option value to rotate its value to the next in the list of values.
Changing the page size can improve performance for the following reasons:
• Storing and retrieving Blob data is most efficient when the entire Blob fits on a single database page.
If an application stores many Blobs exceeding 4KB, using a larger page size reduces the time for
accessing Blob data.
• InterBase performs better if rows do not span pages. If a database contains long rows of data, consider
increasing the page size.
• If a database has a large index, increasing the database page size reduces the number of levels in
the index tree. Indexes work faster if their depth is kept to a minimum. Choose Database|Mainte-
nance|Database Statistics to display index statistics, and consider increasing the page size if index
depth is greater than three on any frequently used index.
• If most transactions involve only a few rows of data, a smaller page size may be appropriate, because
less data needs to be passed back and forth and less memory is used by the disk cache.
4.3. Restore Type
Option values are Create Database | Replace Database | Create Tablespace | Replace Tablespace.
To restore a database over an existing database, you must be the owner of the existing database or SYSDBA.
IMPORTANT
Do not replace an existing database while clients are operating on it. When restoring to an existing file name, a safer
approach is to rename the existing database file, restore the database, then drop or archive the old database as needed.
Normally, IBConsole restores all metadata before restoring any data. If you set the Commit After Each
Table option value to True, IBConsole restores the metadata and data for each table together, committing
one table at a time.
This option is useful when you are having trouble restoring a backup file. This can happen if the data is
corrupt or is invalid according to integrity constraints.
If you have a problem backup file, restoring the database one table at a time lets you recover some of
the data intact. You can restore only the tables that precede the bad data; restoration fails the moment
it encounters bad data.
4.6. Deactivate Indexes
Option values are True and False.
Normally, InterBase rebuilds indexes when a database is restored. If the database contained duplicate
values in a unique index when it was backed up, restoration fails. Duplicate values can be introduced into
a database if indexes were temporarily made inactive (for example, to allow insertion of many records or
to rebalance an index).
To enable restoration to succeed in this case, set the Deactivate Indexes option to True. This makes indexes
inactive and prevents them from rebuilding. Then eliminate the duplicate index values, and re-activate
indexes through ALTER INDEX in isql.
A unique index cannot be activated using the ALTER INDEX statement; a unique index must be dropped
and then created again. For more information about activating indexes, see the Language Reference.
TIP
The Deactivate Indexes option is also useful for bringing a database online more quickly. Data access is slower until
indexes are rebuilt, but the database is available. After the database is restored, users can access it while indexes are
reactivated.
4.7. Validity Conditions
Option values are Restore and Ignore.
If you redefine validity constraints in a database where data is already entered, your data might no longer
satisfy the validity constraints. You might not discover this until you try to restore the database, at which
time an error message about invalid data appears.
IMPORTANT
Always make a copy of metadata before redefining it; for example, by extracting it using isql.
To restore a database that contains invalid data, set the Validity Conditions option to Ignore. This option
deletes validity constraints from the metadata. After the database is restored, change the data to make it
valid according to the new integrity constraints. Then add back the constraints that were deleted.
This option is also useful if you plan to redefine the validity conditions after restoring the database. If you
do so, thoroughly test the data after redefining any validity constraints.
To restore a database with 100% fill ratio on every data page, set the Use All Space option to True. By
default, space is reserved for each row on a data page to accommodate a back version of an UPDATE or
DELETE. Depending on the size of the compressed rows, that could translate to any percentage.
To monitor the restore process as it runs, set the Verbose Output option to To Screen. This option opens
a standard text display window to display status messages during the restore. For example:
The standard text display window enables you to search for specific text, save the text to a file, and print
the text. For an explanation of how to use the standard text display window, see Text Viewer Window.
When enabled, journal archiving allows databases to recover from a complete loss of an InterBase server
machine to within a few minutes of when the disaster occurred, or to a specific point in time.
This chapter defines key terms such as journal, journal file, and journal archive, and explains how to im-
plement and use them with your database.
NOTE
Journaling is available in the Server Edition of InterBase, starting from version 2007. It is not available in the Desktop
Edition.
A journal archive is a directory that contains a full database dump and all the journal files completed since
that dump. You can use the journal archive to recover to the last transaction recorded in the most recently
archived journal file. You can also use an archived journal file to perform point-in-time recovery. Point-in-
time recovery uses the internal timestamp that is recorded on each transaction in the file, which allows you
to, if desired, recover to a specific date and time.
To save changed pages in the database cache to the hard disk, you set up journaling checkpoints to
occur automatically. A checkpoint specifies the time at which InterBase must save all the changed pages in
the database cache to the database file. After the checkpoint has been reached, the data in the journal file
is no longer needed, so the file can be reused. For best performance, place the journal files on a dedicated
hard drive. The journal files must be on the database server machine.
Journaling guarantees that all changes are on disk before a transaction is marked committed as long as
O/S and hardware caching are disabled.
You do not need to use journal archiving to use journaling and journal files. However, journal archiving
lets you recover from a disaster that completely destroys the database server.
When a database is configured for direct I/O, adding journaling does not automatically convert the
database to asynchronous buffered I/O as it does when the database is configured for synchronous buffer
I/O. This is to avoid buffered I/O at all costs when the database is set to direct I/O.
InterBase uses buffered file I/O on all platforms to perform I/O on database pages for the file on disk.
The pages are delivered via the System File Cache, which acts as a duplicate store of the pages on RAM.
Subsequent loads of the same page(s) are quickly served by the OS kernel if the page exists in the System
File Cache. On systems where there is high contention with other files for the System File Cache (a shared
pool used by all processes for buffered file I/O) the performance of InterBase may not be optimal. If
available System File Cache is limited due to RAM resource limitations, the kernel must spend time cleaning
up unused blocks of memory from other processes as well as provide for servicing a new block I/O request.
The performance problem is alleviated by using "direct I/O" (also known as non-buffered I/O) so blocks of
pages are directly read from the disk into the process space and do not need to use the System File Cache.
This is supported on Windows OS only. This setting is not supported on non-Windows platform databases;
you will see the following error.
If a database enabled with "direct" I/O is then copied to an older version of InterBase, the setting will not
be used by the older InterBase server. The older server will employ the "sync" write mode in this case.
The gfix command line tool has been modified to allow setting a database to be in "direct" I/O write mode.
For example:
The gbak command line tool now has a new restore option (optional) setting to override a database write
mode. The "write" mode will be preserved during a backup/restore lifecycle.
Services API support for the new and updated gfix and gbak options.
You can find the various new agruments and respective values in ibase.h
Argument: isc_spb_res_write_mode
Purpose: Set the write mode of the database. The next byte must be one of:
gstat command line tool will exhibit the following setting,direct, in its "Attributes" header line output.
. . .
It is important to note that a database needs to be set with "gfix -write direct" option and reloaded by the
database engine for this to take effect.
Also, since the System File Cache will not be used when "direct" I/O is set, it is recommended that the
database cache setting and database linger interval be set suitably. This allows the most frequently used
pages to be in memory, the InterBase database cache, when new connections are serviced.
This "direct" I/O setting on a database is only possible if the database page size is an exact multiple of the
underlying disk sector size of the file. The standard for so many decades has been 512 bytes per sector on
hard disks. Newer hard disks however are trying to adopt the more Advanced Format of 4096 bytes per
sector. InterBase supports the following database page sizes: 1024, 2048, 4096, 8192 and 16384 bytes per
page. Databases that have a page size of 1024 or 2048 bytes cannot be set to "direct" I/O on hard disks
that only support the 4096 bytes per sector standard; you need to restore your database to a larger page
size on such disks before enabling "direct" I/O on them.
If you try to enable "direct" I/O on an incompatible device, the following error message is returned stating
the minimum required database page size. The following example shows an error message where the disk
sector size is 4096 bytes.
IMPORTANT
For disaster recovery purposes, a journal archive should always be located on a different machine — ideally, in a remote
location — than the one that houses the database server.
Only completed journal files are archived to the archive directory. This means that up to the moment
recovery is possible when the hard drive that contains the current, active, unarchived journal file remains
intact. However, if disaster wipes out the hard drive that contains the active, incomplete journal file, the
data on that file will also be lost.
NOTE
Before you can activate journal archiving, you must first enable journaling. For instructions on how to do so, see Enabling
Journaling and Creating Journal Files. For instructions on how to activate journal archiving, see Using Journal Archiving.
• The I/O speed of the device on which the journal files are created.
• The speed of concurrent creation of new journal files.
• Hardware requirements and ease of setup.
It is not necessary for InterBase to be installed and running on the machine used for journal archive storage.
1.2.1. Additional Considerations
• A journal archive is platform-specific. For example, an archive created with InterBase for Windows
cannot be directly used to recover an InterBase database on another platform. Instead, an archived
database dump could be logically backed up in transportable format and then logically restored on
the other platform.
• Only full dumps are archived. You cannot archive incremental database dumps. The gbak -
archive_database command initiates a full, physical backup. For more information about InterBase
backup options, see About InterBase backup and restore options
• The journal and journal archive are restricted to a single directory. The number of items allowed to be
archived will be limited by the number of files that are allowed in a directory for a given file system.
NOTE
InterBase currently requires that all journal files be stored in the same directory.
All CREATE JOURNAL clauses are optional. Table 1.1 describes the function of each option and its default
value.
If used, the base journal file name will be appended with a timestamp in the
following format:
YYYY_MM_DDTHH_MM_SSZ.sequence_number.journal
[NO] PREALLOCATE Specifies the amount of disk space preallocated for journal files. For more in- No default val-
formation about using the preallocate clause, see About Preallocating Journal ue.
Space.
The CREATE JOURNAL statement causes all subsequent write operations on a database to be done asyn-
chronously. The journal file I/O is always synchronous and cannot be altered. All transaction changes are
safely recorded on durable storage before the transaction is committed. This guarantees the ACID proper-
ties of a transaction (the database industry standards for Atomicity, Consistency, Isolation, and Durability).
Using asynchronous I/O for database writes allows the operating system to optimize file I/O, such as by
writing consecutive pages together, or by using scatter/gather techniques that write consecutive pages
in discontiguous page buffers. Journal file I/O is performed using InterBase careful write strategy. This
implies that database pages can be written back to the database in any order after their changes have
been journaled.
During a database checkpoint, any database page writes that were buffered asynchronously are flushed
to disc before checkpoint completion is signaled. You can re-enable synchronous writes for the database,
which removes the requirement for a flush operation before a database checkpoint can be considered
complete. Doing so, however, can degrade performance.
If the journal is not on a dedicated drive, you can use the PREALLOCATE clause to allocate space equal to
the size of the maximum number of journal files that might exist. This guarantees that other files cannot
consume the space that may be needed for the journal. If journal archiving is enabled, and you are archiving
to a remote machine, allocate enough space to accommodate the journal files that will accumulate if the
connection to the remove machine is lost and the journal files cannot be archived for a period of time.
You can use the following equations to help you determine the most efficacious rollover frequency for your
journal files. You can enter the resulting number in the LENGTH clause of the CREATE JOURNAL statement,
which specifies when the end of a journal file is reached. When the end of the file is reached, journaling
resumes on a new file. When a journal file is complete (i.e. its end has been reached), it can be saved to
the archive directory.
To determine a rollover interval, you can use either of the following equations:
(journal file length * journal page size) / (database page size * writes
per minute) = # of minutes between rollovers
The equation above lets you see how often a rollover will occur for a given journal file length. The equation
below calculates the journal length that will give the rollover interval you specify:
You can use the following equations to help you determine the most effective checkpoint interval for your
system:
To help determine the time your system needs to recover, use this equation:
NOTE
This equation assumes that the journal file is processed at a rate of one megabyte per second during crash recovery.
Typically, a journal file is processed at one to two megabytes per second.
To determine checkpoint length for a given recovery time, use this equation:
gstat <a_database> -l
1. In the tree pane, right-click the database for which to initiate journaling, and select Backup/Restore
from the context menu.
2. When the Backup/Restore menu options appear, select Create Journal. The Create Journal dialog
appears, as shown in the figure:
3. On Create Journal, specify the options to use, then choose OK to begin journaling. For descriptions
of each option, see Enabling Journaling and Creating Journal Files.
DROP JOURNAL
NOTE
NOTE
where <journal archive directory> is the location in which InterBase stores the journal archive. If the direc-
tory does not exist or is not accessible, InterBase returns an error message. The directory path can be a
local drive, a mapped drive, or an UNC path (as long as the underlying file APIs can open the file using that
specification). If you do not specify a journal archive directory in the CREATE JOURNAL ARCHIVE statement,
InterBase uses the journal directory created with the CREATE JOURNAL statement.
When you do not activate journal archiving, the current journal files are reused after a checkpoint writes
the records of a jounal file to the hard drive.
IMPORTANT
You only use the CREATE JOURNAL ARCHIVE command to initiate journal archiving on a database. Once you initiate
archiving and InterBase performs the first dump, you use the gbak -archive_database command, discussed below,
to perform subsequent dumps. If you disable journal archiving and want to resume it, use CREATE JOURNAL ARCHIVE.
To copy completed journal files to the archive directory, use the following syntax:
where <dbname> specifies the database that is being archived. The journal archive will grow in storage size
as the most recently completed journal files are continually archived. For instructions on how to manage
archive size, see Managing Archive Size.
This command performs a full, physical dump to the archive directory, which helps to reduce the number
of journal files that must be stored. The older a dump is, the more journal files InterBase needs to keep
the archive up-to-date.
• How much data can you afford to lose if the IB server is destroyed?
• What is the journal rollover frequency? There is no reason to archive journal files more often that the
journal rollover interval.
• Frequent journal rollover + frequent journal archiving means minimum data loss. However, too fre-
quent journal rollover + too frequent journal archiving means poor performance. What is the best
balance for your system?
Disabling journal archiving does not disable database journaling (the creation of journal files). The database
will continue to use the write-ahead protocol to commit database changes to the journals. If the intent is
to also disable journaling, then you must execute a separate DROP JOURNAL statement, shown in Disabling
Journal Files.
If you do not use the -UNTIL switch, InterBase recovers the database to the last committed transaction
in the most recently archived journal file or to the last committed transaction in the current, active journal
file if the current, active journal file is accessible. The -until <timestamp> instructs InterBase to recover
transactions until the date and time you specify.
It is recommended that you start building a new archive soon after a successful recovery event. You can
create a new archive by issuing the gbak -archive_database and the gbak -archive_journals commands.
• Run the gbak -archive_database command to create a new dump, thereby reducing the number of
journal files InterBase needs to keep the archive up-to-date.
• Run the gfix command to set a maximum number of dumps to allow in the archive:
When the number of database dumps in the archive exceeds the <number> given, older dumps and
journals will be deleted.
• Run the gfix -archive_sweep command to manually control archive size (described below).
To remove all files in an archive with a sequence number lower than a number you specify, use the following
syntax:
If an archived item cannot be swept (garbage-collected), the sweep will stop and return an error status.
Sometimes all lower sequenced items cannot be deleted. For example, a database dump may depend on
a lower sequenced journal file with which to start recovery. In that case, InterBase will automatically adjust
the given sequence number to a lower number, so that this dependency is not lost.
The following table describes column and data type information for RDB$JOURNAL_ARCHIVES.
Given a database that has an 8KB page size, the journal PAGE SIZE will default to 16KB (2 x 8KB). Therefore,
the LENGTH parameter (65000)will cause rollover to a new journal file every 1GB (65000 x 16KB). If you
instead set the LENGTH at 500, the system would roll over to a new journal file every 8MB, which is extremely
frequent. A performance drop may occur during this process. Using a larger LENGTH value will make this
occur (65000/500 or 130 times) less often.
The CHECKPOINT LENGTH parameter of 10000 means the database checkpoint will occur every 160MB (10000 x
16KB). Assume the built-in CHECKPOINT LENGTH is 500, which means your system will checkpoint the database
every 8MB (500 x 16KB). CHECKPOINT LENGTH is a matter of individual taste. It represents the maximum
number of bytes that will have to be applied to a database from the journal files after a system crash. You can
expect to average between 1MB to 2MB/sec. applying the journal files during the recovery process. So the
160MB checkpoint length suggested here would take a maximum of about 2 minutes to recover depending
on your machine. If your organization can tolerate a longer recovery time in return for minimizing the
online frequency of database checkpoints, then raise the CHECKPOINT LENGTH accordingly.
The PAGE CACHE parameter can be raised to reduce the probability of incurring journal buffer wait states. At
any moment, the journal cache writer thread will be syncing some number of journal buffers to the journal
file on disk. During this period, we want to insure that the worker threads have enough spare journal buffers
to write to when a database page's journal changes need to be moved to a journal buffer.
For example, imagine that the journal cache writer is syncing 500 journal buffers to disk. The 2500 journal
buffer configuration will leave 2000 spare buffers for the worker threads to dump their journal changes.
At the built-in PAGE CACHE default of 100, the worker threads can stall due to a high rate of journal buffer
wait states.
Lastly, the use of a SAN mirrored cache will always make InterBase journaling sub-system result in lower
performance than a non-journaled InterBase database. This is because twice the amount of data is being
written with the journaling subsystem: once to the journal files and once to the database files, plus the
additional CPU cost of journal cache management in the InterBase server.
Even for direct-attached storage, it is necessary to pay attention to on-disk write cache enablement. New
computers sometimes arrive with on-disk write cache enabled. This means that synchronous writes to a
database or journal are not really synchronized to disk oxide. Unless the write cache (SAN or direct) has
been disabled or has battery backup, it cannot offer durability for database commits.
InterBase journaling should only result in a performance gain when disk I/O is write-through, where every
database write goes to disk oxide and not an on-disk cache.
Hopefully, the CREATE JOURNAL statement above will minimize this cost. Remember that the end goal is
to provide point-in-time disaster recovery using the CREATE JOURNAL ARCHIVE statement to archive time-
consistent database dumps and journal files.
This activates journal archiving and performs the initial database dump.
Then copy the completed journal files to the archive directory, using the following syntax:
Now, in the archive directory listing below, the database dump, EMPLOY-
EE.2006-08-21T15-48-17Z.1.DATABASE, has no database changes made after 2006-08-21 15:48:17. It does
not care what updates are going to the main database while it is being dumped or after it is finished
dumping. This includes the checkpoint process.
This is what the log page of the main database looked like at precisely 2006-08-2115:48:17. If you attempt to
recover using this database dump, it will start with journal file, EMPLOYEE.2006-08-21T15-45-11Z.1.JOUR-
NAL, at offset 5694 and continue through the last journal file or whatever timestamp was specified with
an optional -UNTIL clause:
GBAK -ARCHIVE_R
E:\EMPLOYEE_JOURNALS_AND_ARCHIVES\EMPLOYEE.2006-08-21T15-48-17Z.1.DATABASE
E:\EMPLOYEE_RECOVER\EMPLOYEE.GDB -UNTIL "2006-08-21 18:08:15"
GBAK -ARCHIVE_DATABASE (creating archive db dump) never locks anything. The only archive management
restriction is that archive operations are serialized. You cannot do multiple GBAK/GFIX operations against
it at the same time. The important point here is that the main database is fully accessible at all times.
GBAK -ARCHIVE_JOURNALS <my_database> causes non-archived journal files to be copied to the archive (or
marked as archived as above) when you do not want to dump the whole database. Again, a row is entered
into RDB$JOURNAL_ARCHIVES for each archived journal file.
GFIX -ARCHIVE_SWEEP <sequence no.> <my_database> deletes all files in RDB$JOURNAL_ARCHIVES with RDB
$ARCHIVE_SEQUENCE less than the requested sequence.
GFIX -ARCHIVE_DUMPS <number> <my_database> configures the maximum number of database dumps al-
lowed in the archive. After issuing GBAK -ARCHIVE_DATABASE, archive management will automatically delete
the oldest archive database dump and all earlier journal files if the dump limit has been exceeded by the
addition of the new database dump.
Archive directories can be located on InterBase servers or passive file servers and appliances. The archived
files are opened directly by clients and not through an InterBase server. Archive database dumps are sealed
so you can simultaneously run database validation (usually requires exclusive), logical GBAK, and have
multiple, same-platform machines on the network attach the database for read-only queries, which implies
high levels of page I/O over the network.
If the most current, non-archived journal files are accessible from the machine where the recover is being
executed, then the recovery process will “jump” to those journal files to recover the most recently commit-
ted transactions, notwithstanding the optional -UNTIL clause. The recovered database is divorced of any
journal or journal archive so it is necessary to define them again if desired.
However, it is more useful to leave the recovered database in a perpetual state of long term recovery. That
is, every time after the first GBAK -ARCHIVE_RECOVER, subsequent GBAK -ARCHIVE_RECOVER statements
apply the incremental journal changes. This provides perfect symmetry with the online dump feature:
NOTE
This functional modification is much more efficient. Full, archival recovery can take hours depending on
the volume of journal changes.
If you divorce from the database, you save 1 second in not having to type GFIX -MODE READ_WRITE at
the cost of having to create another full recovery if you want a more recent copy (hour(s)). Now you have
to run GFIX -MODE READ_WRITE to divorce, but you gain hours of efficiency by being able to get the
incremental journal changes since the last GBAK -ARCHIVE_RECOVER. This also means that the recovered
database can be deployed more quickly if the main database is lost. It also can function as a more up-to-
date READ_ONLY database for queries and reporting purposes.
Lastly, the journal archive is never implicitly dropped as a side-effect of DROP DATABASE or DROP JOUR-
NAL. It is necessary to explicitly issue a DROP JOURNAL ARCHIVE statement before DROP DATABASE. The
journal archive potentially represents the last known source of the contents of a dropped database so it
is intentionally difficult to delete.
Although it has always been possible to see a list of users who were currently attached to a database, you
can now find out much more. For example, you can see how long each user has been connected, what
application each user is running, or the total amount of data I/O used by each attachment. A glance at
the temporary table metadata listed in the Language Reference Guide will suggest the vast possibilities
that are available here.
It is also possible to exercise a certain amount of control over the state of a database by performing updates
to these tables. See Updating System Temporary Tables.
These system temporary tables are specific to each database attachment and are visible only to the sysdba
user and the database owner. There is therefore no need for unique names and no danger of collisions
by separate attachments. Each table is populated only at the point when a client queries it.
The following system temporary tables are available. Their structure is documented in the Language Ref-
erence Guide.
TIP
For frequent monitoring, the best transaction control is to start the transaction as READ_COMMITTED, READ_ONLY. Then
commit it with COMMIT_RETAINING. This has the least impact on the system.
SHOW SYSTEM
The temporary tables are listed at the end of the system tables. To see the metadata for a particular table,
issue:
NOTE
The SHOW SYSTEM command is available only in command-line isql, not in InterBase Windows isql.
1.1.3. Security
Unlike system tables, which have a default access privilege of SELECT for PUBLIC users, the temporary tables
have no default access by PUBLIC. The display and manipulation of this runtime information is restricted to
SYSDBA and the database owner. These two users have the option of using the GRANT statement to allow
access to other users. The statement can grant only SELECT privileges.
Action Statement
To roll back an active transaction UPDATE TMP$TRANSACTIONS SET TMP$STATE ='ROLLBACK'WHERE TMP$TRANSAC-
TION_ID=123;
To roll back a limbo transaction UPDATE TMP$TRANSACTIONS SET TMP$STATE ='ROLLBACK'WHERE TMP$TRANSAC-
TION_ID=123;
Action Statement
To commit a limbo transaction UPDATE TMP$TRANSACTIONS SET TMP$STATE ='COMMIT'WHERE TMP$TRANSAC-
TION_ID=123;
To cancel the attachment’s cur- UPDATE TMP$ATTACHMENTS SET TMP$STATE ='CANCEL'WHERE TMP$ATTACHMEN-
rently executing operation T_ID=123;
To shut down the current at- UPDATE TMP$ATTACHMENTS SET TMP$STATE ='SHUTDOWN'WHERE TMP$ATTACH-
tachment MENT_ID=123;
To make an executing statement UPDATE TMP$STATEMENTS SET TMP$STATE ='CANCEL'WHERE TMP$STATEMEN-
stop running T_ID=123;
NOTE
Shutting down an attachment detaches the user from the database and terminates the local or network attachment
to the server.
Action Statement
To roll back all active UPDATE TMP$TRANSACTIONS SET TMP$STATE ='ROLLBACK'WHERE TMP$STATE ='ACTIVE';
transactions
To roll back all limbo UPDATE TMP$TRANSACTIONS SET TMP$STATE ='ROLLBACK'WHERE TMP$STATE ='LIMBO';
transactions
To commit all limbo UPDATE TMP$TRANSACTIONS SET TMP$STATE ='COMMIT'WHERE TMP$STATE ='LIMBO';
transactions
• Select a connected database in the Tree pane and choose Database|Maintenance|Database Statistics.
• Select a connected database in the Tree pane and double-click Database Statistics in the Work pane.
• Right-click a connected database in the Tree pane and choose Maintenance|Database Statistics from
the context menu.
A Database Statistics dialog appears where you can select which statistics you want to display.
1. Select the statistical data you wish to generate from the Options list.
You can specify options by entering a value, by clicking the option value and choosing a new value
from a drop-down list of values or by double-clicking the option value to rotate its value to the next
in the list of values.
2. Click OK to generate database statistics.
NOTE
In some cases, it can take a long time to display the statistics for large databases because, depending on what infor-
mation has been selected to report, generating these statistics may analyze all the tables and indexes in a database.
The Database Statistics report dialog is a standard text display window that exhibits database summary
and database analysis information statistics. For an explanation of how to use the standard text display
window, see Text Viewer Window.
NOTE
In addition to the selected statistic, header page information is displayed, regardless which statistic has been selected
to report. If Header Pages is the selected option value, then only header page information will be displayed.
2.1.1. All Options
Displays statistic information for all options including Data Pages, Database Log, Header Pages, Index
Pages, and System Relations.
2.1.2. Data Pages
Displays data page information in the database summary. Below is an example of data page information,
followed by an explanation of each item.
COUNTRY (31)
Primary pointer page: 246, Index root page: 247
Data pages: 1, data page slots: 1, average fill: 59%
Fill distribution:
0 - 19% = 0
20 - 39% = 0
40 - 59% = 1
60 - 79% = 0
80 - 99% = 0
The first line displays a database table name while the remaining lines contain item information pertaining
to the table. These items include:
2.1.3. Database Log
Displays the database log in the database summary. Below is an example of database log information.
2.1.4. Header Pages
Displays header page information in the database summary. Below is an example of database summary
header page information, followed by an explanation of each item.
Database "C:\Embarcadero\InterBase\examples\Database\employee.ib"
Database header page information:
Flags 0
Checksum 12345
Generation 41
Page size 4096
ODS version 12.0
Oldest transaction 29
Oldest active 30
Oldest snapshot 30
Next transaction 34
Bumped transaction 1
Sequence number 0
Next attachment ID 0
Implementation ID 16
Shadow count 0
Page buffers 0
Next header page 0
Database dialect 1
Creation date Aug 26, 2006 17:05:03
Variable header data:
Sweep interval: 20000
*END*
The first line displays the name and location of the primary database file while the remaining lines contain
information on the database header page. These items include:
The difference between the oldest transaction and the next transaction determines when database
sweeping occurs. For example, if the difference is greater than this difference (set to 20,000 by de-
fault), then InterBase initiates a database sweep. See Overview of Sweeping.
• 1 HP Apollo Domain OS
• 2 Sun Solaris SPARC, HP9000 s300, Xenix, Motorola IMP UNIX, UnixWare, NCR UNIX, NeXT, Data
General DG-UX Intel
• 3 Sun Solaris x86
• 4 VMS
• 5 VAX Ultrix
• 6 MIPS Ultrix
• 7 HP9000 s700/s800
• 8 Novell NetWare
• 9 Apple Macintosh 680x0
• 10 IBM AIX POWER series, IBM AIX PowerPC
• 11 Data General DG-UX 88K
• 12 HP MPE/xl
• 13 SGI IRIX
• 14 Cray
• 15 SF/1
• 16 Microsoft Windows 7 (32-bit and 64-bit)
• 17 OS/2
• 18 Windows 16 bit
• 19 LINUX on Intel series
• 20 LINUX on Sparc systems
• 21 DARWIN on Intel
• 22 DARWIN on PowerPC
• 23 DARWIN on iOS ARM architecture
• 24 Android on x86 architecture (emulator)
• 25 Android on ARM architecture (device
Shadow count The number of shadow files defined for the database.
Number of cache The number of page buffers in the database cache.
buffers
Next header page The ID of the next header page.
Database dialect The SQL dialect of the database
Creation date The date when the database was created.
Attributes
• force write—indicates that forced database writes are enabled.
• no_reserve—indicates that space is not reserved on each page for old generations of data. This
enables data to be packed more closely on each page and therefore makes the database occu-
py less disk space.
• shutdown—indicates database is shut down.
Variable header
data • sweep interval
• secondary file information
2.1.5. Index Pages
Displays index information in the database summary. Below is an example of index page information,
followed by an explanation of each item.
2.1.6. System Relations
Displays information for system tables in the database.
RDB$CHECK_CONSTRAINTS (24)
Primary pointer page: 54, Index root page: 55
Data pages: 5, data page slots: 5, average fill: 59%
Fill distribution:
0 - 19% = 0
20 - 39% = 1
40 - 59% = 0
60 - 79% = 4
80 - 99% = 0
Index RDB$INDEX_14 (0)
Depth: 1, leaf buckets: 1, nodes: 68
Average data length: 0.00, total dup: 14, max dup: 1
Fill distribution:
0 - 19% = 0
20 - 39% = 0
40 - 59% = 1
60 - 79% = 0
80 - 99% = 0
The statistics contained here are similar to that of data pages and index pages. For information on the
items see Data Pages and Index Pages above.
• Select a database (or any branch under the database hierarchy) in the Tree pane and choose Database|
Connected Users.
• Select a database in the Tree pane and double-click Connected Users in the Actions column of the
Work pane.
• Right-click a database in the Tree pane and choose Connected Users from the context menu.
NOTE
InterBase temporary system tables provide resources for more extensive monitoring of database activity. See Monitoring
with System Temporary Tables.
Description: The gstat program is a command-line tool for retrieving and reporting database statistics.
Its function is the same as that described for IBConsole earlier in this chapter.
You must be SYSDBA or the owner of a database to run gstat. On UNIX platforms, there is a further
constraint on gstat: in order to run gstat, you must have system-level read access to the database files.
You can gain this by logging in as the same account that the InterBase server is running as (InterBase or
root) or by setting the system-level permissions on the database file to include read permission for your
Group. These restrictions exist on UNIX platforms because gstat accesses the database file at the system
level rather than through the InterBase server.
NOTE
You can run gstat only against local databases: run gstat on the server host.
Option Description
-all Equivalent to supplying -index and -data; this is the default if you supply none of -index, -data, or -all.
-data Retrieves and displays statistics on data tables in the database.
-header Stops reporting statistics after reporting the information on the header page.
-index Retrieves and displays statistics on indexes in the database.
-log Stops reporting statistics after reporting the information on the log pages.
-pa[ssword] Checks for password <text> before accessing a database.
text
-r[ecord] Adds lines for average record length and average version length to the table statistics.
-system Retrieves statistics on system tables and indexes in addition to user tables and indexes.
-t[able] Outputs index and fill information for the requested table, in addition to database header, file, and log
statistics; table name is case sensitive.
-username Checks for user <name> before accessing database.
-z Prints product version of gstat.
Example: The following command requests table statistics, including record and version length for the
JOB table in employee.ib:
Database "employee.ib"
Generation 26
Page size 4096
ODS version 15.0
Oldest transaction 19
Oldest active 20
Oldest snapshot 20
Next transaction 21
Sequence number 0
Next attachment ID 0
Implementation ID 16
Shadow count 0
Page buffers 0
Next header page 0
Database dialect 1
Creation date Jul 9, 2010 19:58:59
Attributes force write
JOB (129)
Primary pointer page: 178, Index root page: 179
Average record length: 64.87, total records: 31, max record length:
77
Average version length: 0.00, total versions: 0, max versions: 0
Data pages: 3, data page slots: 3, average fill: 72%
0 - 19% = 1
20 - 39% = 0
40 - 59% = 0
60 - 79% = 0
80 - 99% = 0
Locking is a mechanism that InterBase uses to maintain the consistency of the database when it is accessed
by multiple users. The lock manager is a thread in the ibserver process that coordinates locking.
The lock manager uses a lock table to coordinate resource sharing among client threads in the ibserver
process connected to the database. The lock table contains information on all the locks in the system and
their states. The global header information contains useful aggregate information such as the size of the
lock table, the number of free locks, the number of deadlocks, and so on. There is also process information
such as whether the lock has been granted or is waiting. This information is useful when trying to correct
deadlock situations.
The first form of syntax given above retrieves a report of lock statistics at one instant in time. The second
form monitors performance by collecting samples at fixed intervals.
The options display interactive information on current activity in the lock table. The utility prints out the
events per second for each sampling and gives the average of the values in each column at the end.
Option Description
[none] Same as -o
-a Prints a static view of the contents of the lock table.
-o Prints a static lock table summary and a list of all entities that own blocks.
-w Prints out all the information provided by the -o flag plus wait statistics for each owner; this option helps
to discover which owner’s request is blocking others in the lock table.
The following options supply interactive statistics (events/second) for the requested items, which are sampled <n> times
every <t> seconds, with one line printed for each sample. The average of the sample values is printed at the end of each
column. If you do not supply values for <n> and <t>, the default is <n>=1.
-i Prints all statistics; the output is easier to read if you issue -ia, -io, and -iw separately.
-ia Prints how many threads are trying to acquire access to the lock table per second.
-io Prints operation statistics such lock requests, conversions, downgrades, and releases per second.
-iw Prints number of lock acquisitions and requests waiting per second, wait percent, and retries.
t Specifies the time in seconds between samplings.
n Specifies the number of samples to be taken.
Example: The following statement prints “acquire” statistics (access to lock table: acquire/s, acqwait/s, %ac-
qwait, acqrtry/s, and rtrysuc/s) every three seconds until ten samples have been taken:
gds_lock_print -ia 3 10
You can use the API function isc_database_info( ) to retrieve statistics, by specifying one or more of the
following request buffer items:
See the API Guide for information on request buffers, and details of using this API call.
Interactive Query
This chapter documents the IBConsole interactive SQL (isql) and command-line isql utilities for InterBase.
These tools provide an interface to InterBase Dynamic SQL interpreter. You can use these query tools to
perform data definition, prototype queries before implementing them in your application, or to perform
ad hoc examination of data in your database. Refer to Interactive SQL Window documentation for an over
view of this tool.
To avoid cluttering the Windows directory with InterBase temporary files, specify a different directory for
them by defining the TMP environment variable.
When you exit, isql deletes these temporary files. If isql terminates abnormally, then these files remain and
may be freely deleted without any adverse effects. You should not delete any of these temporary files while
isql is running, because they may be used in the current session.
1. Type a single SQL statement in the SQL input area. Make sure any other existing statements are
commented. A statement is commented if it is preceded by “/*” and followed by “*/”.
If the statement already exists in the SQL input area make sure all statements except the one you wish to
execute are commented. Commented statements in the SQL input area are ignored during execution.
If more than one statement is uncommented, Execute executes each statement, one after the other.
TIP
You can copy text from other Windows applications such as the Notepad and Wordpad text editors and paste it into
the SQL input area. You can also copy statements from the isql output area and paste them into the SQL input area.
This cut-and-paste method is also a convenient way to use the online SQL tutorial provided in the online Help.
When SQL statements are executed, whether successfully or not, they become part of the isql command
history, a sequential list of SQL statements entered in the current session.
For example, the SET NAMES statement cannot be executed from the SQL input area. To change the active
character set, choose Edit|Options and select the desired character set option value in the SQL Options
dialog.
• SQL script files can include statements that are not valid to enter interactively. For example, you can
use the SET statements such as SET LIST in scripts.
• Transaction names may not be used with SET TRANSACTION statement.
• The SQL input area accepts multiple statements, although only one can be executed at a time. Each
statement entered in the SQL input area must be terminated by a semicolon (;). The SQL input area
accepts multiple statements, although only one can be executed at a time. An uncommented state-
ment that holds the mouse cursor is called the current statement.
NOTE
Statements executed from a loaded script file do not become part of the command history.
NOTE
Batch updates only work using the InterBase 2007 client library and an InterClient JDBC driver.
You can send multiple INSERT, UPDATE, and DELETE statements to the server using batch updates. In response,
the server returns an array of ULONG values that reflect the number of affected rows per statement.
SQL statements such as SELECT and CREATE DATABASE are not supported in batch updates. SQL DDL is
supported.
The following diagram shows the flow of communication between client and server when completing a
number of INSERT statements using traditional InterBase client APIs. Note the flow of communication shown
in the figure also applies to UPDATE and DELETE statements.
The following diagram shows the flow of communication when using batch updates. Note the reduction
in network traffic, resulting in better performance.
BATCH START;
...
(allowed DDL/DML statements)
...
BATCH EXECUTE;
The BATCH EXECUTE command sends the statements between BATCH START and BATCH EXECUTE to the server.
To begin another batch operation, you must issue another BATCH START command.
The following demonstrates a specific example of using batch mode with isql.
BATCH START;
The first SQL statement in the example inserts a new row into table t1. The second statement updates the
newly inserted row with a new value. Both of these statements are executed in one API call.
For details on how to use the batch_excute and batch_execute_immed functions, see Chapter 15 of the
InterBase API Guide.
NOTE
The AUTOCOMMITDDL mode of isql must be turned off in order to use batch updates.
Changes made to the database by data manipulation (DML) statements—for example INSERT and UPDATE—
are not permanent until they are committed. Commit changes by choosing Transactions|Commit or by
clicking Commit on the toolbar.
To undo all database changes from DML statements since the last commit, choose Transactions|Rollback
or click Rollback on the toolbar.
• SQL statements entered in the SQL input area of the current session.
To save the SQL statements entered in the SQL input area of the current session to a text file:
1. In the SQL Editor, choose Menu|Query>Save Script or click the Save Script toolbar button.
2. Enter a file name, including the location for the new file, in the Save As dialog and click Save.
To include the location for the file, type the file path and file name in the Filename text area, or browse to
the folder where you would like the file to reside and type only the file name.
Only the SQL statements entered in the current session, not the output, are saved to the specified file.
To include the location for the file, either type the file path and file name in the Filename text area, or
browse to the folder where you would like the file to reside and type only the file name.
The output in the Data tab from the last successful statement is saved to the named text file.
If you run a SQL script, and then choose to save the output, all the commands in the script file and their
results are saved to the output file. If command display has been turned off in a script with SET ECHO OFF,
then SQL statements in the script are not saved to the file.
To open the object inspector, double-click a database object in the Work pane. The object inspector ap-
pears:
Depending on the database object selected, the object inspector has some or all of the following tabs:
Properties, Metadata, Permissions, Data, and Dependencies. These are discussed in the following sections.
4.2. Viewing Metadata
The metadata which the Metadata tab of the object inspector displays depends on the database that is
selected in the Tree pane, or the item that is selected in the Work pane.
To view metadata for an entire database Select a connected database in the Tree pane, and then
double-click View Metadata in the Work pane. The metadata is displayed in a text window.
To view metadata for a specific database object perform one of the following actions:
• Select a database element from the hierarchy displayed in the Tree pane, and then in the Work pane
double-click an object to display its Properties dialog. Click the Metadata tab to see the object’s
metadata.
• Select a database element from the hierarchy displayed in the Tree pane, and then in the Work pane
right-click a database object associated with that element and select Extract from the context menu.
For example, if you want metadata for domains only, expand the desired database hierarchy (if it is not
already expanded), select Domains, double-click on a domain in the Work pane, and select the Metadata
tab of the Properties dialog.
Use the drop-down list at the top of the dialog to select other objects associated with the database element.
The following table lists the items for which you can view metadata for associated objects with the object
inspector.
4.3. Extracting Metadata
You can extract a metadata script to a file by displaying the desired metadata in the Metadata tab and
clicking the Save Script toolbar button.
Extracting an entire database exports metadata in a specific order, to allow the resulting script to be used
as input to recreate the database.
Metadata Comments
1. Database Extracts database with default character set and PAGE_SIZE.
2. Domains Must be before tables that reference domains.
3. Tables Must be after domains.
4. Indexes Must be after tables.
Metadata Comments
5. FOREIGN KEY Must be added after tables to avoid tables being referenced before they have been created.
constraints
6. Views Must be after tables.
7. CHECK con- Must be after tables.
straints
8. Exceptions Must be extracted before stored procedures and triggers that contain code to raise exceptions.
9. Stored proce- Stored procedures are shown with no body in CREATE PROCEDURE and then ALTER PROCEDURE to
dures add the text of the procedure body; this is to allow circular or recursive procedure references.
10. Triggers Must be after tables.
• Code of external functions or filters, because that code is not part of the database. The declarations
to the database (with DECLARE EXTERNAL FUNCTION and DECLARE FILTER) are extracted.
• System tables, system views, and system triggers.
• Because DDL statements do not contain references to object ownership, the extracted file does not
show ownership. The output file includes the name of the object and the owner if one is defined.
There is no way to assign an object to its original owner.
For a description of the standard SQL commands available in isql, see the Language Reference Guide.
For a description of special isql commands, see Isql Command Reference.
5.1. Invoking isql
To start the isql utility, type the following at a UNIX shell prompt or Windows console prompt:
where options are command-line options and <database_name> is the name of the database to connect
to, including disk and directory path.
If no options are specified, isql starts an interactive session. If no database is specified, you must connect
to an existing database or create a new one. If a database was specified, isql starts the interactive session
by connecting to the named database.
If options are specified, isql starts interactively or noninteractively, depending on the options. For example,
reading an input file and writing to an output file are noninteractive tasks, so the -input or -output options
do not start an interactive session. Additional noninteractive options include -a, -database, -extract, and
-x, which are used when extracting DDL statements.
When you start an interactive isql session, the following prompt appears:
SQL>
You must then end each command with a terminator character. The default terminator is a semicolon (;).
You can change the terminator to any character or group of characters with the SET TERMINATOR command
or with the -terminator command-line option. If you omit the terminator, a continuation prompt appears
(CON>).
NOTE
For clarity, all of the commands and examples in this chapter end with the default semicolon terminator.
5.1.1. Command-line Options
Only the initial characters in an option are required. You can also type any portion of the text enclosed in
brackets, including the full option name. For example, specifying -n, -no, or -noauto has the same effect.
Option Description
-a Extracts all DDL for the named database.
-c[ache] Set number of cache buffers for this connection to the database; see Default Cache
Size Per isql Connection.
-d[atabase] <name> Used with -x; changes the CREATE DATABASE statement that is extracted to a file.
• Without -d, CREATE DATABASE appears as a C-style comment and uses the
database name specified on the isql command line.
• With -d, isql extracts an uncommented CREATE DATABASE and substitutes
<name> as its database argument.
-e[cho] Displays (echoes) each statement before executing it.
-ex[tract] Same as -x
-i[nput] <file> Reads commands from an input file such as a SQL script file instead of from standard
input.
• input files can contain -input commands that call other files, enabling execution
to branch and then return.
• isql exits (with a commit) when it reaches the end of the first file.
• In interactive sessions, use -input to read commands from a file.
-m[erge_stderr]
• Merges stderr output with stdout.
Option Description
• Useful for capturing output and errors to a single file when running isql in a shell
script or batch file.
-names <character set Specifies the character set to use for current database attachment. Default is NONE.
name>
Note: Any SET NAMES call in isql or inside an SQL script overrides the character set
that you provide in the command-line.
-n[oauto] Turns off automatic commit of DDL statements; by default, DDL statements are com-
mitted automatically in a separate transaction.
-nowarnings Displays warning messages if, and only if, an error occurs (be default, isql displays any
message returned in a status vector, even if no error occurred).
-o[utput] file Writes results to an output file instead of to standard output; in interactive sessions,
use -output to write results to a file.
-pas[sword] password Used with -user
• For access, both <password> and <user> must represent a valid entry in the se-
curity database.
-x Extracts DDL for the named database; displays DDL to the screen unless redirected to a
file.
-z Displays the software version of isql.
5.1.2. Using Warnings
Warnings can be issued for the following conditions:
• The following example starts an interactive connection to a remote database. The remote server,
jupiter, accepts the specified user and password combination with the privileges assigned to the STAFF
role:
• The next example starts an interactive session but does not attach to a database. isql commands are
displayed, and query results print column headers every 30 lines:
QUIT;
EXIT;
You can connect to either local or remote databases. The syntax is slightly different for the two:
To connect to a local database on a Windows platform, use the CONNECT command with the full path
of the database as the argument. For example:
To connect to a remote database on a Windows or UNIX server using TCP/IP, use the CONNECT command
with the full node name and path of the database as the argument. Separate the node name from the
database path with a colon.
NOTE
Be careful not to confuse node names and shared disks, since both are specified with a colon separator. If you specify
a single letter that maps to a disk drive, it is assumed to be a drive, not a node name.
TIP
You can use either forward slashes ( / ) or backslashes ( \ ) as directory separators. InterBase automatically converts
either type of slash to the appropriate type for the server operating system.
isql -sql_dialect n
• If you start isql and attach to a database without specifying a dialect, isql takes on the dialect of
the database.
• If you specify a dialect on the command line when you invoke isql, it retains that dialect after con-
nection unless explicitly changed.
• When you change the dialect during a session using SET SQL DIALECT n, isql continues to operate
in that dialect until it is explicitly changed.
• When you create a database using isql, the database is created with the dialect of the isql client; for
example, if isql has been set to dialect 1, when you create a database, it is a dialect 1 database.
• If you create a database without first specifying a dialect for the isql client or attaching to a database,
isql creates the database in dialect 3.
The statements above are true whether you are running isql as a command-line utility or accessing it
through IBConsole.
IMPORTANT
Any InterBase isql client that attaches to a Version 5 database resets to dialect 1.
isql uses a separate transaction for DDL statements. When these statements are issued at the SQL> prompt,
they are committed automatically as soon as they are completed. DDL scripts should issue a COMMIT after
every CREATE statement to ensure that new database objects are available to all subsequent statements
that depend on them. For more information on DDL statements, see the Data Definition Guide.
The -x option is an abbreviation for -extract. The -a flag directs isql to extract all database objects. Note
that the output file specification, <outputfile>, must follow the -output flag, while you can place the name
of the database being extracted at the end of the command.
• Examine the current state of a database’s system tables before you plan alterations to it, or when a
database has changed significantly since its creation.
• Use your text editor to make changes to the database definition or create a new database source file.
The -extract option does not extract UDF code and Blob filters, because they are not part of the database.
It does extract the declarations to the database (with DECLARE EXTERNAL FUNCTION and DECLARE FILTER).
The -extract option also does not extract system tables, system views, or system triggers.
Because DDL statements do not contain references to object ownership, the extracted file does not show
ownership. The output file includes the name of the object and the owner if one is defined. There is no
way to assign an object to its original owner.
For a list of the order of extraction of metadata objects, see Extracting Metadata.For example, the following
statement extracts the system catalogs from the database employee.ib to a file called employee.sql:
The resulting output script is created with -commit following each set of commands, so that tables can be
referenced in subsequent definitions. This command extracts all keywords and object names in uppercase
when possible (some international metadata has no uppercase).
To extract DDL statements from database employee.ib and store in the file employee.sql, enter:
The following example extracts the DDL statements from the database dev.ib:
isql -x dev.ib
This example combines the -extract and -output options to extract the DDL statements from the database
dev.ib into a file called dev.out. The output database name must follow the -output flag.
5.5. isql Commands
At the SQL> prompt, you can enter any of three kinds of commands:
• SQL data definition (DDL) statements, such as CREATE, ALTER, DROP, GRANT, and REVOKE. These state-
ments create, modify, or remove metadata and objects, and control user access (via privileges) to the
database. For more information about DDL, see the Data Definition Guide.
• SQL data manipulation (DML) statements such as SELECT, INSERT, UPDATE, and DELETE. These four data
manipulation operations affect the data in a database. They retrieve, modify, add, or delete data. For
more information about DML statements, see the Language Reference.
• isql commands that fall into three main categories:
• SHOW commands (to display metadata or other database information)
• SET commands (to modify the isql environment)
• Other commands (for example, commands to read an input file, write to an output file, or end an
isql session)
Some isql commands have many options. See Isql Command Reference
5.5.1. SHOW Commands
SHOW commands are used to display metadata, including tables, indexes, procedures, and triggers.
SHOW commands list all of the specified objects or give information about a particular object when used
with <name.>
SHOWcommands operate on a separate transaction from user statements. They run as READ COMMITTED
background statements and acknowledge all metadata changes immediately.
5.5.2. SET Commands
SET commands enable you to view and change the isql environment.
SQL> QUIT;
SQL> EXIT;
For a detailed discussion of error handling, see the Embedded SQL Guide. For a complete listing of SQL-
CODE and InterBase status array codes, see the Language Reference Guide.
For a list of the standard DSQL commands available in isql, see Statement and Function Reference (Lan-
guage Reference Guide) in the Language Reference Guide.
Command Topic
BLOBDUMP BLOBDUMP
EDIT EDIT
EXIT EXIT
HELP HELP
INPUT INPUT
OUTPUT OUTPUT
QUIT QUIT
RECONNECT RECONNECT
SET SET
SET AUTODDL SET AUTODDL
SET BLOBDISPLAY SET BLOBDISPLAY
SET COUNT SET COUNT
SET ECHO SET ECHO
SET LIST SET LIST
SET NAMES SET NAMES
SET PLAN SET PLAN
SET STATS SET STATS
SET TERM SET TERM
SET TIME SET TIME
SET SUBSCRIPTION SET SUBSCRIPTION
SHELL SHELL
SHOW CHECK SHOW CHECK
SHOW DATABASE SHOW DATABASE
SHOW DOMAINS SHOW DOMAINS
SHOW EXCEPTIONS SHOW EXCEPTIONS
SHOW FILTERS SHOW FILTERS
SHOW FUNCTIONS SHOW FUNCTIONS
SHOW GENERATORS SHOW GENERATORS
SHOW GRANT SHOW GRANT
SHOW INDEX SHOW INDEX
SHOW INDICES SHOW INDEX
SHOW PROCEDURES SHOW PROCEDURES
SHOW ROLES SHOW ROLES
SHOW SUBSCRIPTION SHOW SUBSCRIPTION
SHOW SUBSCRIPTIONS
SHOW SYSTEM SHOW SYSTEM
Command Topic
SHOW TABLES SHOW TABLES
SHOW TRIGGERS SHOW TRIGGERS
SHOW VERSION SHOW VERSION
SHOW VIEWS SHOW VIEWS
6.1. BLOBDUMP
Places the contents of a BLOB column in a named file for reading or editing.
Argument Description
<blob_id> System-assigned hexadecimal identifier, made up of two hexadecimal numbers separated by a colon (:)
Description: BLOBDUMP stores Blob data identified by <blob_id> in the file specified by <filename>.
Because binary files cannot be displayed, BLOBDUMP is useful for viewing or editing binary data. BLOB-
DUMP is also useful for saving blocks of text (Blob data) to a file.
To determine the blob_id to supply in the BLOBDUMP statement, issue any SELECT statement that selects a
column of Blob data. When the table’s columns appear, any Blob columns contain hexadecimal Blob IDs.
The display of Blob output can be controlled using SET BLOBDISPLAY.
Example: Suppose that Blob ID 58:c59 refers to graphical data in JPEG format. To place this Blob data
into a graphics file named picture.jpg, enter:
6.2. EDIT
Allows editing and re-execution of isql commands.
EDIT [filename];
Argument Description
<filename> Name of the file to edit
• A source file and then execute the commands upon exiting the editor.
• The current isql session, then re-execute them.
On Windows platforms, EDIT calls the text editor specified by the EDITOR environment variable. If this
environment variable is not defined, then EDIT uses the Microsoft Notepad editor.
On UNIX, EDIT calls the text editor specified by either the VISUAL environment variable or EDITOR, in that
order. If neither variable is defined, then EDIT uses the vi editor.
If given filename as an argument, EDIT places the contents of filename in an edit buffer. If no file name is
given, EDIT places the commands in the current isql session in the edit buffer.
After exiting the editor, isql automatically executes the commands in the edit buffer.
Filenames with spaces You can optionally delimit the filename with double or single quotes. This allows
you to use filenames with spaces in EDIT statements.
Examples: To edit the commands in a file called start.sql and execute the commands when done, enter:
EDIT START.SQL;
In the next example, a user wants to enter SELECT DISTINCT JOB_CODE, JOB_TITLE FROM JOB; interactively:
Instead, the user mistakenly omits the DISTINCT keyword. Issuing the EDIT command opens the statement
in an editor and then executes the edited statement when the editor exits.
6.3. EXIT
Commits the current transaction, closes the database, and ends the isql session.
EXIT;
Description: Both EXIT and QUIT close the database and end an isql session. EXIT commits any changes
made since the last COMMIT or ROLLBACK, whereas QUIT rolls them back.
IMPORTANT
EXIT commits changes without prompting for confirmation. Before using EXIT, be sure that no transactions need to
be rolled back.
6.4. HELP
Displays a list of isql commands and short descriptions.
HELP;
Description: HELP lists the built-in isql commands, with a brief description of each.
OUTPUT isqlhelp.lst;
HELP;
OUTPUT;
After issuing the HELP command, use OUTPUT to redirect output back to the screen.
6.5. INPUT
Read and execute commands from the named file.
INPUT filename;
Argument Description
<filename> Name of the file containing SQL statements and SQL commands
Description: INPUT reads commands from <filename> and executes them as a block. In this way, INPUT
enables execution of commands without prompting. <filename> must contain SQL statements or isql
commands.
Input files can contain their own INPUT commands. Nesting INPUT commands enables isql to process mul-
tiple files. When isql reaches the end of one file, processing returns to the previous file until all commands
are executed.
The INPUT command is intended for noninteractive use. Therefore, the EDIT command does not work in
input files.
Using INPUT <filename> from within an isql session has the same effect as using -inputfilename from
the command line.
Unless output is redirected using OUTPUT, any results returned by executing filename appear on the screen.
You can optionally delimit the filename with double or single quotes. This allows you to use filenames with
spaces in INPUT statements.
Examples: For this example, suppose that file add.lst contains the following INSERT statement:
INPUT ADD.lst;
For the next example, suppose that the file, table.lst, contains the following SHOW commands:
INPUT TABLE.lst;
To record each command and store its results in a file named table.out, enter
6.6. OUTPUT
Redirects output to the named file or to standard output.
OUTPUT [filename];
Argument Description
<filename> Name of the file in which to save output; if no file name is given, results appear on the standard output
Description: OUTPUT determines where the results of isql commands are displayed. By default, results are
displayed on standard output (usually a screen). To store results in a file, supply a <filename> argument. To
return to the default mode, again displaying results on the standard output, use OUTPUT without specifying
a file name.
By default, only data is redirected. Interactive commands are not redirected unless SET ECHO is in effect.
If SET ECHO is in effect, isql displays each command before it is executed. In this way, isql captures both
the results and the command that produced them. SET ECHO is useful for displaying the text of a query
immediately before the results.
NOTE
Using OUTPUT <filename> from within an isql session has the same effect as using the option -outputfile-
name from the command line.
You can optionally delimit the filename with double or single quotes. This allows you to use filenames with
spaces in OUTPUT statements.
Example: The following example stores the results of one SELECT statement in the file, sales.out. Normal
output processing resumes after the SELECT statement.
OUTPUT sales.OUT;
SELECT * FROM SALES;
OUTPUT;
6.7. QUIT
Rolls back the current transaction, closes the database, and ends the isql session.
QUIT;
Description: Both EXIT and QUIT close the database and end an isql session. QUIT rolls back any changes
made since the last COMMIT or ROLLBACK, whereas EXIT commits the changes.
IMPORTANT
QUIT rolls back uncommitted changes without prompting for confirmation. Before using QUIT, be sure that any changes
that need to be committed are committed. For example, if SET AUTODDL is off, DDL statements must be committed
explicitly.
6.8. SET
Lists the status of the features that control an isql session.
SET;
Description: isql provides several SET commands for specifying how data is displayed or how other
commands are processed.
The SET command, by itself, verifies which features are currently set. Some SET commands turn a feature
on or off. Other SET commands assign values.
Many isqlSET commands have corresponding SQL statements that provide similar or identical functionality.
In addition, some of the isql features controlled by SET commands can also be controlled using isql
command-line options. SET Statements are used to configure the isql environment from a script file.
Changes to the session setting from SET statements in a script affect the session only while the script is
running. After a script completes, the session settings prior to running the script are restored.
SET Statements
Statement Description Default
SET AUTODDL Toggles the commit feature for DDL statements. ON
SET BLOBDISPLAY <n> Turns on the display of Blob type <n>; the parameter <n> is required to display OFF
Blob types.
SET COUNT Toggles the count of selected rows on or off. OFF
SET ECHO Toggles the display of each command on or off. OFF
SET LIST <string> Displays columns vertically or horizontally. OFF
SET NAMES Specifies the active character set. OFF
SET PLAN Specifies whether or not to display the query plan of the optimizer. OFF
SET STATS Toggles the display of performance statistics on or off. OFF
SET TERM <string> Allows you to change to an alternate terminator character (deprecated in Inter- ;
Base 7 and later).
SET Statements
Statement Description Default
SET TIME Toggles display of time in DATE values. ON
By default, all settings are initially OFF except AUTODDL and TIME, and the terminator is a semicolon (;). Each
time you start an isql session or execute an isql script file, settings begin with their default values.
SET statements are used to configure the isql environment from a script file. Changes to the session setting
from SET statements in a script affect the session only while the script is running. After a script completes,
the session settings prior to running the script are restored to their values before the script was run. So
you can modify the settings for interactive use, then change them as needed in an isql script, and after
running the script they automatically return to their previous configuration.
NOTE
• You cannot enter isqlSET statements interactively in the SQL Statement area of IBConsole isql. You can perform
the same functions with menu items.
• SET GENERATOR and SET TRANSACTION (without a transaction name) are DSQL statements and so you can enter
them interactively in IBConsole isql or isql. These statements are not exclusively isql statements, so they are not
documented in this chapter. See the Language Reference Guide for details.
• SET DATABASE is exclusively an embedded SQL statement. See the Language Reference Guide and the Embedded
SQL Guide for details.
SET;
Print statistics: OFF
Echo commands: OFF
List format: OFF
ROW COUNT: OFF
Autocommit DDL: OFF
The output shows that isql is set to not echo commands, to display Blob data if they are of subtype 1 (text),
to automatically commit DDL statements, and to recognize a semicolon (;) as the statement termination
character.
6.9. SET AUTODDL
Specifies whether DDL statements are committed automatically after being executed or committed only
after an explicit COMMIT.
Argument Description
ON Turns on automatic commitment of DDL [default]
OFF Turns off automatic commitment of DDL
Description: SET AUTODDL is used to turn on or off the automatic commitment of data definition language
(DDL) statements. By default, DDL statements are automatically committed immediately after they are
executed, in a separate transaction. This is the recommended behavior.
If the OFF keyword is specified, auto-commit of DDL is then turned off. In OFF mode, DDL statements can
only be committed explicitly through a user’s transaction. This mode is useful for database prototyping,
because uncommitted changes are easily undone by rolling them back.
TIP
The ON and OFF keywords are optional. If they are omitted, SET AUTO switches from one mode to the other. Although
you can save typing by omitting the optional keyword, including the keyword is recommended because it avoids po-
tential confusion.
Examples: The following example shows part of an isql script that turns off AUTODDL, creates a table named
TEMP, then rolls back the work.
. . .
SET AUTO OFF;
CREATE TABLE TEMP (a INT, b INT);
ROLLBACK;
. . .
This script creates TEMP and then rolls back the statement. No table is created. because its creation was
rolled back.
The next script uses the default AUTODDL ON. It creates the table TEMP and then performs a rollback:
. . .
CREATE TABLE TEMP (a INT, b INT);
ROLLBACK;
. . .
Because DDL is automatically committed, the rollback does not affect the creation of TEMP.
6.10. SET BLOBDISPLAY
Specifies subtype of Blob data to display.
Argument Description
<n> Integer specifying the Blob subtype to display
• To display Blob data of a particular subtype, use SET BLOBDISPLAY <n>. By default, isql displays Blob
data of text subtype (<n> = 1).
• To display Blob data of all subtypes, use SET BLOBDISPLAY ALL.
• To avoid displaying Blob data, use SET BLOBDISPLAY OFF. Omitting the OFF keyword has the same
effect. Turn Blob display off to make output easier to read.
In any column containing Blob data, the actual data does not appear in the column. Instead, the column
displays a Blob ID that represents the data. If SET BLOBDISPLAY is on, data associated with a Blob ID appears
under the row containing the Blob ID. If SET BLOBDISPLAY is off, the Blob ID still appears even though its
associated data does not.
Examples: The following examples show output from the same SELECT statement. Each example uses a
different SET BLOB command to affect how output appears. The first example turns off Blob display.
With BLOBDISPLAY OFF, the output shows only the Blob ID:
PROJ_NAME PROJ_DESC
==================== =================
Video DATABASE 24:6
DigiPizza 24:8
AutoMap 24:a
MapBrowser port 24:c
Translator upgrade 24:3b
Marketing project 3 24:3d
The next example restores the default by setting BLOBDISPLAY to subtype 1 (text).
SET BLOB 1;
SELECT PROJ_NAME, PROJ_DESC FROM PROJECT;
Now the contents of the Blob appear below each Blob ID:
PROJ_NAME PROJ_DESC
==================== =================
Video DATABASE 24:6
==============================================================
PROJ_DESC:
Design a video DATA base management system FOR
controlling on-demand video distribution.
PROJ_NAME PROJ_DESC
==================== =================
DigiPizza 24:8
==============================================================
PROJ_DESC:
Develop SECOND generation digital pizza maker
WITH flash-bake heating element AND
digital ingredient measuring system.
. . .
6.11. SET COUNT
Specifies whether to display number of rows retrieved by queries.
Argument Description
ON Turns on display of the “rows returned” message
OFF Turns off display of the “rows returned” message [default]
Description: By default, when a SELECT statement retrieves rows from a query, no message appears to
say how many rows were retrieved.
Use SET COUNT ON to change the default behavior and display the message. To restore the default behavior,
use SET COUNT OFF.
TIP
The ON and OFF keywords are optional. If they are omitted, SET COUNT switches from one mode to the other. Although
you can save typing by omitting the optional keyword, including the keyword is recommended because it avoids po-
tential confusion.
Example: The following example sets COUNT ON to display the number of rows returned by all following
queries:
COUNTRY CURRENCY
=============== ==========
SWITZERLAND SFRANC
FRANCE FFRANC
BELGIUM BFRANC
3 ROWS returned
6.12. SET ECHO
Specifies whether commands are displayed to the isql output area before being executed.
Argu- Description
ment
ON Turns on command echoing [default]
OFF Turns off command echoing
Description: By default, commands in script files are displayed (echoed) in the isql output area, before
being executed. Use SET ECHO OFF to change the default behavior and suppress echoing of commands.
This can be useful when sending the output of a script to a file, if you want only the results of the script
and not the statements themselves in the output file.
Command echoing is useful if you want to see the commands as well as the results in the isql output area.
TIP
The ON and OFF keywords are optional. If they are omitted, SET ECHO switches from one mode to the other. Although you
can save typing by omitting the optional keyword, including the keyword is recommended because it avoids potential
confusion.
Example: Suppose you execute the following script from IBConsole isql:
. . .
SET ECHO OFF;
SELECT * FROM COUNTRY;
SET ECHO ON;
SELECT * FROM COUNTRY;
EXIT;
The output (in a file or the isql output area) looks like this:
. . .
SET ECHO OFF;
COUNTRY CURRENCY
=========== ========
USA Dollar
England Pound
. . .
. . .
The first SELECT statement is not displayed, because ECHO is OFF. Notice also that the SET ECHO ON statement
itself is not displayed, because when it is executed, ECHO is still OFF. After it is executed, however, the second
SELECT statement is displayed.
6.13. SET LIST
Specifies whether output appears in tabular format or in list format.
Argument Description
ON Turns on list format for display of output
OFF Turns off list format for display of output [default]
Description: By default, when a SELECT statement retrieves rows from a query, the output appears in a
tabular format, with data organized in rows and columns.
Use SET LIST ON to change the default behavior and display output in a list format. In list format, data
appears one value per line, with column headings appearing as labels. List format is useful when columnar
output is too wide to fit nicely on the screen.
TIP
The ON and OFF keywords are optional. If they are omitted, SET LIST switches from one mode to the other. Although
you can save typing by omitting the optional keyword, including the keyword is recommended because it avoids po-
tential confusion.
Now suppose you precede the SELECT with SET LIST ON:
JOB_CODE SRep
JOB_GRADE 4
JOB_COUNTRY Italy
JOB_TITLE Sales Representative
6.14. SET NAMES
Specifies the active character set to use in database transactions.
Argument Description
<charset> Name of the active character set; default is NONE.
Description: SET NAMES specifies the character set to use for subsequent database connections in isql. It
enables you to override the default character set for a database. To return to using the default character
set, use SET NAMES with no argument.
Use SET NAMES before connecting to the database whose character set you want to specify. For a complete
list of character sets recognized by InterBase, see the Language Reference.
Choice of character set limits possible collation orders to a subset of all available collation orders. Given a
specific character set, a specific collation order can be specified when data is selected, inserted, or updated
in a column.
Example: The following statement at the beginning of a script file indicates to set the active character set
to ISO8859_1 for the subsequent database connection:
6.15. SET PLAN
Specifies whether to display the optimizer’s query plan.
Argument Description
ON Turns on display of the optimizer’s query plan
OFF Turns off display of the optimizer’s query plan [default]
Description: By default, when a SELECT statement retrieves rows from a query, isql does not display the
query plan used to retrieve the data.
Use SET PLAN ON to change the default behavior and display the query optimizer plan. To restore the
default behavior, use SET PLAN OFF.
To change the query optimizer plan, use the PLAN clause in the SELECT statement.
TIP
The ON and OFF keywords are optional. If they are omitted, SET PLAN switches from one mode to the other. Although you
can save typing by omitting the optional keyword, including the keyword is recommended because it avoids potential
confusion.
Example: The following example shows part of a script that sets PLAN ON:
The output then includes the query optimizer plan used to retrieve the data as well as the results of the
query:
6.16. SET STATS
Specifies whether to display performance statistics after the results of a query.
Argument Description
ON Turns on display of performance statistics
OFF Turns off display of performance statistics [default]
Description: By default, when a SELECT statement retrieves rows from a query, isql does not display
performance statistics after the results. Use SET STATS ON to change the default behavior and display
performance statistics. To restore the default behavior, use SET STATS OFF. Performance statistics include:
Performance statistics can help determine if changes are needed in system resources, database resources,
or query optimization.
TIP
The ON and OFF keywords are optional. If they are omitted, SET STATS switches from one mode to the other. Although
you can save typing by omitting the optional keyword, including the keyword is recommended because it avoids po-
tential confusion.
Do not confuse SET STATS with the SQL statement SET STATISTICS, which recalculates the selectivity of
an index.
Example: The following part of a script file turns on display of statistics and then performs a query:
The output displays the results of the SELECT statement and the performance statistics for the operation:
JOB_COUNTRY MIN_SALARY
=============== ======================
France 118200.00
6.17. SET TIME
Specifies whether to display the time portion of a DATE value.
Argument Description
ON Turns on display of time in DATE value.
OFF Turns off display of time in DATE value [default].
Description: The InterBase Date data type includes a date portion (including day, month, and year) and
a time portion (including hours, minutes, and seconds).
By default, isql displays only the date portion of Date values. SET TIME ON turns on the display of time
values. SET TIME OFF turns off the display of time values.
TIP
The ON and OFF keywords are optional. If they are omitted, the command toggles time display from ON to OFF or OFF
to ON.
Example: The following example shows the default display of a DATE data type, which is to display day,
month, and year:
This example shows the effects of SET TIME ON, which causes the hours, minutes and seconds to be displayed
as well:
6.18. SHELL
Allows execution of an operating system command or temporary access to an operating system shell.
SHELL [os_command];
Argument Description
<os_command> An operating system command; if no command is specified, isql provides interactive access to the
operating system
Description: The SHELL command provides temporary access to operating system commands in an isql
session. Use SHELL to execute an operating-system command without ending the current isql session.
If <os_command> is specified, the operating system executes the command and then returns to isql
when complete.
If no command is specified, an operating system shell prompt appears, enabling you to execute a sequence
of commands. To return to isql, type exit. For example, SHELL can be used to edit an input file and run
it at a later time. By contrast, if an input file is edited using the EDIT command, the input file is executed
as soon as the editing session ends.
Using SHELL does not commit transactions before it calls the shell.
Example: The following example uses SHELL to display the contents of the current directory:
SHELL DIR;
6.19. SHOW CHECK
Displays all CHECK constraints defined for a specified table.
Argument Description
<table> Name of an existing table in the current database
Description: SHOW CHECK displays CHECK constraints for a named table in the current database. Only us-
er-defined metadata is displayed. To see a list of existing tables, use SHOW TABLE.
Example: The following example shows CHECK constraints defined for the JOB table. The SHOW TABLES
command is used first to display a list of available tables.
SHOW TABLES;
COUNTRY CUSTOMER
DEPARTMENT EMPLOYEE
EMPLOYEE_PROJECT JOB
PHONE_LIST PROJECT
PROJ_DEPT_BUDGET SALARY_HISTORY
SALES
6.20. SHOW DATABASE
Displays information about the current database.
Description: SHOW DATABASE displays the current database’s file name, page size and allocation, and sweep
interval.
The output of SHOW DATABASE is used to verify data definition or to administer the database. For example,
use the backup and restore utilities to change page size or reallocate pages among multiple files, and use
the database maintenance utility to change the sweep interval.
Example: The following example connects to a database and displays information about it:
CONNECT 'employee.ib';
DATABASE: employee.ib
SHOW DB;
DATABASE: employee.ib
Owner: SYSDBA
PAGE_SIZE 4096
NUMBER OF DB pages allocated = 422
6.21. SHOW DOMAINS
Lists all domains or displays information about a specified domain.
Argument Description
<name> Name of an existing domain in the current database
Options: To see a list of existing domains, use SHOW DOMAINS without specifying a domain name. SHOW DOMAIN
name displays information about the named domain in the current database. Output includes a domain’s
data type, default value, and any CHECK constraints defined. Only user-defined metadata is displayed.
Example: The following example lists all domains and then shows the definition of the domain, SALARY:
SHOW DOMAINS;
FIRSTNAME LASTNAME
PHONENUMBER COUNTRYNAME
ADDRESSLINE EMPNO
DEPTNO PROJNO
CUSTNO JOBCODE
JOBGRADE SALARY
BUDGET PRODTYPE
PONUMBER
SHOW DOMAIN SALARY;
SALARY NUMERIC(15, 2) NULLABLE
DEFAULT 0
CHECK (VALUE > 0)
6.22. SHOW EXCEPTIONS
Lists all exceptions or displays the text of a specified exception.
Argument Description
<name> Name of an existing exception in the current database
Description: SHOW EXCEPTIONS displays an alphabetical list of exceptions. SHOW EXCEPTION name displays
the text of the named exception.
Examples: To list all exceptions defined for the current database, enter:
SHOW EXCEPTIONS;
Exception Name Used BY, TYPE
================== ========================================
UNKNOWN_EMP_ID ADD_EMP_PROJ, Stored PROCEDURE
To list the message for a specific exception and the procedures or triggers that use it, enter the exception
name:
6.23. SHOW FILTERS
Lists all Blob filters or displays information about a specified filter.
Argument Description
<name> Name of an existing Blob filter in the current database
Options: To see a list of existing filters, use SHOW FILTERS. SHOW FILTER name displays information about
the named filter in the current database. Output includes information previously defined by the DECLARE
FILTER statement, the input subtype, output subtype, module (or library) name, and entry point name.
Example: The following example lists all filters and then shows the definition of the filter, DESC_FILTER:
SHOW FILTERS;
DESC_FILTER
6.24. SHOW FUNCTIONS
Lists all user-defined functions (UDFs) defined in the database or displays information about a specified
UDF.
Argument Description
<name> Name of an existing UDF in the current database
Options: To see a list of existing functions defined in the database, use SHOW FUNCTIONS. To display informa-
tion about a specific function in the current database, use SHOW FUNCTION <function_name>. Output includes
information previously defined by the DECLARE EXTERNAL FUNCTION statement: the name of the function and
function library, the name of the entry point, and the data types of return values and input arguments.
Example: The following UNIX example lists all UDFs and then shows the definition of the MAXNUM() function:
SHOW FUNCTIONS;
ABS MAXNUM
TIME UPPER_NON_C
UPPER
6.25. SHOW GENERATORS
Lists all generators or displays information about a specified generator.
Argument Description
<name> Name of an existing generator in the current database
Description: To see a list of existing generators, use SHOW GENERATORS. SHOW GENERATOR name displays in-
formation about the named generator in the current database. Output includes the name of the generator
and its next value.
Example: The following example lists all generators and then shows information about EMP_NO_GEN:
SHOW GENERATORS;
Generator EMP_NO_GEN, NEXT VALUE: 146
Generator CUST_NO_GEN, NEXT VALUE: 1016
6.26. SHOW GRANT
Displays privileges for a database object.
Argument Description
<object> Name of an existing table, view, or pro-
cedure in the current database
Description: SHOW GRANT displays the privileges defined for a specified table, view, or procedure. Allowed
privileges are DELETE, EXECUTE, INSERT, SELECT, UPDATE, or ALL. To change privileges, use the SQL statements
GRANT or REVOKE.
Before using SHOW GRANT, you might want to list the available database objects. Use SHOW PROCEDURES to list
existing procedures; use SHOW TABLES to list existing tables; use SHOW VIEWS to list existing views.
6.27. SHOW INDEX
Displays index information for a specified index, for a specified table, or for all tables in the current database.
Argument Description
<index> Name of an existing index in the current database
<table> Name of an existing table in the current database
Description: SHOW INDEX displays the index name, the index type (for example, UNIQUE or DESC), and the
columns on which an index is defined.
If the index argument is specified, SHOW INDEX displays information only for that index. If table is specified,
SHOW INDEX displays information for all indexes in the named table; to display existing tables, use SHOW
TABLES. If no argument is specified, SHOW INDEX displays information for all indexes in the current database.
SHOW INDEX has a shorthand equivalent, SHOW IND. SHOW INDICES is also a synonym for SHOW INDEX. SHOW
INDEXES is not supported.
SHOW INDEX;
RDB$PRIMARY1 UNIQUE INDEX ON COUNTRY(COUNTRY)
CUSTNAMEX INDEX ON CUSTOMER(CUSTOMER)
CUSTREGION INDEX ON CUSTOMER(COUNTRY, CITY)
RDB$FOREIGN23 INDEX ON CUSTOMER(COUNTRY)
. . .
6.28. SHOW PROCEDURES
Lists all procedures or displays the text of a specified procedure.
Argument Description
<name> Name of an existing procedure in the current database
Description: SHOW PROCEDURES displays an alphabetical list of procedures, along with the database objects
they depend on. Deleting a database object that has a dependent procedure is not allowed. To avoid an
isql error, delete the procedure (using DROP PROCEDURE) before deleting the database object.
SHOW PROCEDURE name displays the text and parameters of the named procedure.
Examples: To list all procedures defined for the current database, enter:
SHOW PROCEDURES;
PROCEDURE Name Dependency TYPE
================= ==================== =======
ADD_EMP_PROJ EMPLOYEE_PROJECT TABLE
UNKNOWN_EMP_ID Exception
DELETE_EMPLOYEE DEPARTMENT TABLE
EMPLOYEE TABLE
EMPLOYEE_PROJECT TABLE
PROJECT TABLE
REASSIGN_SALES Exception
SALARY_HISTORY TABLE
SALES TABLE
DEPT_BUDGET DEPARTMENT TABLE
DEPT_BUDGET PROCEDURE
. . .
PROCEDURE text:
============================================================
BEGIN
BEGIN
INSERT INTO EMPLOYEE_PROJECT (EMP_NO, PROJ_ID) VALUES (:emp_no,
:proj_id);
WHEN SQLCODE -530 DO
EXCEPTION UNKNOWN_EMP_ID;
END
RETURN;
END
=================================================================
Parameters:
EMP_NO INPUT SMALLINT
PROJ_ID INPUT CHAR(5)
6.29. SHOW ROLES
Displays the names of SQL roles for the current database.
Description: SHOW ROLES displays the names of all roles defined for the current database. To show user
membership in roles, use SHOW GRANT<rolename>.
Example:
SHOW ROLES;
DOITALL DONOTHING
DOONETHING DOSOMETHING
6.30. SHOW SUBSCRIPTION
SHOW {SUBSCRIPTION [<subscription_name>] | SUBSCRIPTIONS};
Argument Description
<subscription_name> The name of the subscription that you want to display.
Description: To display a list of all subscriptions, use the SHOW SUPSCRIPTIONS command. If you only want
to display one supscription, use the SHOW SUPSCRIPTION <subscription_name> command.
Example:
SHOW SUBSCRIPTIONS;
Subscription Name
===================================================================
SUB_CUSTOMER_DELETES
SUB_EMPLOYEE_CHANGES
SUB_VARIOUS_CHANGES
6.31. SHOW SYSTEM
Displays the names of system tables and system views for the current database.
Description: SHOW SYSTEM lists system tables and system views in the current database. SHOW SYSTEM accepts
an optional keyword, TABLES, which does not affect the behavior of the command.
Example: To list system tables and system views for the current database, enter:
SHOW SYS;
RDB$CHARACTER_SETS RDB$CHECK_CONSTRAINTS
RDB$COLLATIONS RDB$DATABASE
RDB$DEPENDENCIES RDB$EXCEPTIONS
RDB$FIELDS RDB$FIELD_DIMENSIONS
RDB$FILES RDB$FILTERS
RDB$FORMATS RDB$FUNCTIONS
RDB$FUNCTION_ARGUMENTS RDB$GENERATORS
RDB$INDEX_SEGMENTS RDB$INDICES
RDB$LOG_FILES RDB$PAGES
RDB$PROCEDURES RDB$PROCEDURE_PARAMETERS
RDB$REF_CONSTRAINTS RDB$RELATIONS
RDB$RELATION_CONSTRAINTS RDB$RELATION_FIELDS
RDB$ROLES RDB$SECURITY_CLASSES
RDB$TRANSACTIONS RDB$TRIGGERS
RDB$TRIGGER_MESSAGES RDB$TYPES
RDB$USER_PRIVILEGES RDB$VIEW_RELATIONS
6.32. SHOW TABLES
Lists all tables or views, or displays information about a specified table or view.
Argument Description
<name> Name of an existing table or view in the current database
Description: SHOW TABLES displays an alphabetical list of tables and views in the current database. To
determine which listed objects are views rather than tables, use SHOW VIEWS.
SHOW TABLE name displays information about the named object. If the object is a table, command output
lists column names and definitions, PRIMARY KEY, FOREIGN KEY, and CHECK constraints, and triggers. If the
object is a view, command output lists column names and definitions, as well as the SELECT statement that
the view is based on.
Examples: To list all tables or views defined for the current database, enter:
SHOW TABLES;
COUNTRY CUSTOMER
DEPARTMENT EMPLOYEE
EMPLOYEE_PROJECT JOB
PHONE_LIST PROJECT
PROJ_DEPT_BUDGET SALARY_HISTORY
SALES
6.33. SHOW TRIGGERS
Lists all triggers or displays information about a specified trigger.
Argument Description
<name> Name of an existing trigger in the current database
Description: SHOW TRIGGERS displays all triggers defined in the database, along with the table they depend
on. SHOW TRIGGER name displays the name, sequence, type, activation status, and definition of the named
trigger.
Deleting a table that has a dependent trigger is not allowed. To avoid an isql error, delete the trigger (using
DROP TRIGGER) before deleting the table.
Examples: To list all triggers defined for the current database, enter:
SHOW TRIGGERS;
TABLE name TRIGGER name
=========== ============
EMPLOYEE SET_EMP_NO
EMPLOYEE SAVE_SALARY_CHANGE
CUSTOMER SET_CUST_NO
SALES POST_NEW_ORDER
6.34. SHOW VERSION
Displays information about software versions.
SHOW VERSION;
Description: SHOW VERSION displays the software version of isql, the InterBase engine, and the on-disk
structure (ODS) of the database to which the session is attached.
Certain tasks might not work as expected if performed on databases that were created using older versions
of InterBase. To check the versions of software that are running, use SHOW VERSION.
6.35. SHOW VIEWS
Lists all views or displays information about a specified view.
Argument Description
<name> Name of an existing view in the current database
Description: SHOW VIEWS displays an alphabetical list of all views in the current database. SHOW VIEW name
displays information about the named view.
Example: To list all views defined for the current database, enter:
SHOW VIEWS;
PHONE_LIST
Every SQL script file must begin with either a CREATE DATABASE statement or a CONNECT statement (including
username and password) that specifies the database on which the script file is to operate. The CONNECT or
CREATE statement must contain a complete database file name and directory path.
NOTE
You cannot set dialect in a CREATE DATABASE statement. To create a dialect 3 database, specify isql option -r 3.
NOTE
The SQL statement silently fails if significant text follows the terminator character on the same line. Whitespace and
comments can safely follow the terminator, but other statements cannot.
Each SQL script file should end with either EXIT to commit database changes made since the last COMMIT, or
QUIT to roll back changes made by the script. If neither is specified, then database changes are committed
by default.
For the full syntax of CONNECT and CREATE DATABASE, see the Language Reference.
If IBConsole encounters an error, an information dialog appears indicating the error. Once IBConsole
finishes executing the script, the script results are displayed in the SQL output window.
After a script executes, all isql session settings prior to executing the script are restored as well as the
previous database connection, if any. In other words, any isqlSET commands in the script affect only the
isql session while the script is running.
During an active isql session in which you are already connected to a database, you use the INPUT com-
mand to read and execute a SQL script against that database:
NOTE
When creating tables and other database objects with AUTODDL OFF, it is good practice to put a COMMIT statement in the
SQL script after each CREATE statement or group of related statements. This ensures that other users of the database
see the objects immediately.
Changes made to the database by data manipulation (DML) statements—for example INSERT and UPDATE—
are not permanent until they are committed. Commit changes in a script with COMMIT. To undo all database
changes since the last COMMIT, use ROLLBACK. For the full syntax of COMMIT and ROLLBACK, see the Language
Reference book.
1. The simple comment: A comment that starts with a special symbol and ends with a new line.
NOTE
The simple comment syntax is only available starting with database engine version InterBase 2017.
-- comment text
2. The bracketed comment: A comment that starts and ends with a special symbol. It may be mul-
ti-line.
/* comment text
more comment text
another line of comment text
*/
Regardless of the type of comment that you use, you may start a comment anywhere in a line, but with
a simple comment you need to keep in mind that the comment area stops after new line. In order to
use the simple comment syntax for a multi-line comment, you need to start each line with the special
symbol. For example:
/* my multi-line
comment is this
text */
-- my multi-line
-- comment is this
-- text
You can place comments on the same line as code, which makes them inline comments.
It is good programming practice to state the input and output parameters of a procedure in a comment
preceding the procedure. It is also often useful to comment local variable declarations to indicate what
each variable is used for.
Examples The following isql samples illustrate some ways to use comments:
/*
* Procedure DELETE_EMPLOYEE : Delete an employee.
*
* Parameters:
* employee number
* Returns:
* --
*/
CREATE PROCEDURE DELETE_EMPLOYEE (EMP_NUM INTEGER)
AS
DECLARE VARIABLE ANY_SALES INTEGER; -- Number of sales for emp.
BEGIN
. . .
/* This script sets up Change Views Subscriptions
on the EMPLOYEE table.
*/
SHOW SUBSCRIPTIONS;
SELECT COUNT(*)
-- inline comment 1
FROM RDB$DATABASE;
COMMIT;
SET TERM ^;
The guidelines in this chapter are organized into the following categories:
• Hardware configuration
• Operating system configuration
• Network configuration
• Database properties
• Database design principles
• Database tuning tasks
• Application design techniques
• Application development tools
Each project offers unique challenges and requires specific solutions. The suggestions in this chapter aug-
ment your own software engineering discipline, which should include careful analysis, testing, and exper-
imentation to implement the best design for your specific project.
2. Hardware Configuration
This section gives guidelines for platform hardware sizing. The suggestions focus on requirements for a
server platform.
CPU clock speed is often more important on client platforms, because applications that use data might
perform CPU-intensive computational analysis on data, or might render sophisticated visualization of data
in a computationally costly manner.
It’s not appropriate for this document to recommend a specific CPU clock speed for your server, because
it is likely that such a recommendation would be obsolete as you read it. You should evaluate the benefit
of spending more money on a faster CPU, because the price/performance curve becomes steep for the
latest CPU hardware.
2.2. Sizing Memory
It is important to equip your server with a sufficient amount of physical memory to ensure good perfor-
mance.
While InterBase can function in a low-profile hardware configuration, with as little as 32MB of RAM on
most operating systems, it is recommended to have at least 64MB of RAM on a server system. Database
servers that experience a high load can benefit from more RAM.
The base RAM requirement of the ibserver executable and for each connected user is low: approximately
1500KB, plus 28KB for each client connection. ibserver caches metadata and data for each database to
which it connects. User operations such as sorting temporarily consume additional memory. A heavily
loaded server with dozens of clients performing concurrent queries requires up to 256MB of RAM.
On Windows, you can use the Task Manager, Performance Monitor, and other tools to monitor the resource
use of ibserver. UNIX and Linux servers have similar resource consumption reporting tools. Add RAM to
a system that shows too many page faults.
Slow disk subsystems are often the weak link in an otherwise high-performance server machine. The top-
rated CPU and maximum memory helps. But if a cheap disk I/O interface limits the data transfer rate, then
the money spent on the expensive components is wasted.
It’s not appropriate for this document to recommend a particular configuration. The technology changes
so quickly that any recommendation here would be outdated. When you specify the machine for a server
platform, research the best hardware solution available.
• Advanced SCSI technology offers superior I/O throughput. The following graph illustrates the relative
maximum throughput of different disk interfaces.
• The external interface capacity usually exceeds the internal or sustained transfer rate of any individual
device. Only systems that use multiple disk devices make full use of a high-capacity I/O interface.
• Bus-mastering I/O controllers use less CPU resources. This is particularly important on I/O-intensive
server machines. SCSI is generally bus-mastering, and newer PCI EIDE interfaces are bus-mastering.
IDE is not.
• Use a disk controller with built in cache memory. The controller cache reduces the need for the op-
erating system to use system RAM for disk cache.
• Don’t assume all disks of a given size perform equally; research performance ratings made by inde-
pendent testing labs.
2.4. Distributing I/O
Disk device I/O is orders of magnitude slower than physical memory accesses or CPU cycles. There is
a delay while the disk device seeks the data requested. While an application is waiting for data it has
requested from a disk device, it is advantageous for the application to spend the time executing other
tasks. One appropriate way to do this is to spread multiple data requests over multiple devices. While one
disk is preparing to return data, the application requests another disk to start seeking another set of data.
This is called distributed I/O or parallel I/O.
This section describes ways you can persuade InterBase to distribute I/O over multiple disk devices.
2.4.1. Using RAID
You can achieve up to a ten times performance improvement by using RAID.
RAID (redundant array of inexpensive disks) is a hardware design that is intended to give benefits to
performance and reliability by storing data on multiple physical disk devices. It is transparent for software
applications to use RAID, because it is implemented in the operating system or at the hardware level.
InterBase uses operating system I/O interfaces, so InterBase supports RAID as would any other application
software.
Disk striping (included in RAID levels 0, 3, or 5) provides performance benefits by distributing I/O across
multiple disks.
Hardware RAID is faster than software RAID or software disk mirroring. RAID implemented with software
provides only protection from hard disk failure; it is actually slower than operating without RAID.
For example, if you have a server with four physical disks, C:, D:, E:, and F:, and a 10GB database, you
can create your database to take advantage of parallel I/O with the following database creation statement:
For example, if you have sixteen disk devices hosting database files, you might benefit from using four disk
controllers, and attaching four disks to each controller.
For example, on Windows, you could locate the operating system files and pagefile.sys on C:, the tem-
porary directory and infrequently-used files on D:, and database files on drives E: and higher.
Change the location of the InterBase temporary directory by either specifying a system environment vari-
able INTERBASE_TMP, or editing the ibconfig file and specifying the path of the appropriate directory as
a value for the TMP_DIRECTORY entry.
Inexpensive 1000 BASE-T ethernet equipment is common today, but this technology is bare minimum for
LAN configuration. It is recommended to use at least 100 Base-T for a high-performance network. The
following graph illustrates relative bandwidth rates for various network interface technology.
The maximum bandwidth of gigabit ethernet extends beyond the scale of the graph above.
At the time of this writing, most gigabit ethernet network interface cards (NICs) provide only 600 to
700Mbps bandwidth. Switches, routers, and repeaters also have constrained capacity. It is expected that
the state of this technology will continue to improve.
It is recommended that you research reviews and experiment to learn the true throughput of all network
hardware in your environment. The slowest component ultimately determines the true throughput.
TIP
Network cables develop flaws surprisingly frequently. The result can be sporadic lost packets, for which operating sys-
tems compensate by automatically resending packets. This translates into mysterious network performance degrada-
tion. You should test network cables regularly. Replacing flawed cables is a low-cost way to keep your network running
at peak efficiency.
While 32-bit full-duplex PCI bus is capable of up to 264Mbps, PCI cards actually range from 40Mbps to
130Mbps.
TIP
Use controllers on an integrated local PCI bus, it’s faster than peripheral cards that plug into the motherboard.
savers demand a surprising amount of CPU resources to run, and these programs run continuously, 24
hours a day.
Screen savers are evasive in their ability to disappear when a database administrator logs in to the console
to diagnose a mysterious drop in performance. The server seems responsive to the database administrator
as soon as she touches the server, but the speed degrades soon after she leaves the server.
Not all screen savers have the same performance cost. The Windows OpenGL screen savers perform con-
tinuous floating-point computations to draw three-dimensional shaded shapes in real time. They demand
up to 90% of the system CPU, and cause InterBase and other services to slow to one-tenth their normal
speed.
The Windows Marquee screen saver is one of the least demanding ones, especially when it is configured to
pass text across the screen slowly. Some system administrators like to configure a Marquee on each screen
in the machine room, to display the hostname of the respective machine. This becomes a machine-name
label, in raster form.
A screen saver can also be entertainment, but these should be reserved for workstations. A server in a
machine room should be unattended, not used as a workstation.
If you must have phosphor burn protection for a monitor that you leave on, get an Energy Star approved
monitor that has a power conservation mode. This mode blackens the screen after a configurable period
of idleness. This not only protects against phosphor burn, but it conserves power. This is like a simple black
screen saver, but it is handled by the electronics of the monitor, instead of by software.
The best option is to simply turn off the monitor when you are not using it. This saves the phosphors, saves
electricity, and decreases the amount of heat in the machine room.
2.6.3. Console Logins
Do not leave the console logged in on a Windows database server. Even if the desktop is idle, it might
use as much as 30 percent of the CPU resources of the machine just maintaining the interface. You should
log out of the console of the server when you are not using it. IBConsole enables you to perform most
InterBase maintenance and monitoring tasks from another workstation, without logging in at the server’s
console of the server.
The effects of insufficient temporary space include rapid virtual memory page faults, called thrashing, which
causes a dramatic performance penalty. Another possible effect is a series of “I/O error” related messages
printed to the interbase.log file on the server.
Use a secondary server as the file and print server, and a new machine for the database server. Alternately,
use the secondary server for InterBase, depending on the relative priority of these tasks – the database
server benefits from having a dedicated machine, even if it is not the fastest model available. Whatever is
the most important service should be given the best machine as dedicated hardware.
If performance is a high priority, you can spend money more effectively by buying a dedicated machine
instead of trying to increase resources such as RAM on a machine that is providing another competing
service. Compare the cost of the hardware with the cost of having less than maximum performance.
Similarly, it is best to put a database on a dedicated drive, so that the database I/O does not compete
with the operating system virtual memory paging file or other operating system I/O. See Making Drives
Specialized.
This change can result in a dramatic improvement of performance for InterBase, as well as other services.
• Run ibserver on an SMP server that has enough other duties to occupy the other CPU.
• Run ibserver only on a single-CPU machine.
• Assign CPU affinity to the ibserver process:
This technique works only if you run ibserver as an application, not as a service. If you run InterBase as a
service, you must use the Windows API to programmatically set the CPU affinity of the ibserver process.
On some operating systems, using a RAM disk is a technique for forcing very heavily used files to be in
memory, but still allow them to be opened and closed like any other file. If you consider using a RAM disk
on Windows, be aware that the Microsoft RAM disk utility for Windows uses paged memory to allocate the
RAM disk. The RAM disk itself can be paged out of RAM and stored on the physical disk in pagefile.sys.
Therefore, it is futile to use a RAM disk on Windows to create a high-performance file system.
3.1.1. NetBEUI
You can use NetBEUI on a network with fewer than 20 users without significant performance costs. Use
TCP/IP if you have more active users on your network simultaneously.
NetBEUI is a network protocol designed for use on small local area networks. It is commonly used for
filesharing services. It is a connectionless protocol, which means that it broadcasts packets to the entire
network. This causes a growing amount of “noise” on a LAN. Noise, from the point of view of any given
host, can be defined as network traffic that is not intended for that host. On a LAN with many hosts,
enabling NetBEUI can overwhelm the network and reduce the available bandwidth for everyone to use.
On most enterprise networks, IT experts discourage the use of NetBEUI.
3.1.2. TCP/IP
TCP/IP is a connection-based protocol, which means packets are routed to the intended recipient. This
reduces the saturation of the network and the load on individual hosts. There is effectively more bandwidth
available to all hosts, and a large number of hosts can share the same network with less performance
penalty.
Depending on the load on the network and the DNS server itself, hostname resolution can take several
seconds. This translates directly into delays when making a network connection. This is related to the
message you might see in a web browser, “Looking up host name…” followed by, “Connecting to host
name…”. This indicates the delay while querying a DNS server to resolve a hostname.
You can speed up hostname resolution by adding the hostname/address mapping of the database server
to the hosts file on the client computer. The client can resolve the hostname to its address much faster
and more reliably by looking it up in a local file than by querying a service running on another host over
the network. This reduces the hostname resolution delay when initiating connections to hosts listed in the
local hosts file.
NOTE
If you use this technique and later change the address of your database server, you must manually update the hosts
files on each client workstation. Depending on the number of workstations in your enterprise, this can be tedious and
time consuming. That is why DNS was invented, to centralize TCP/IP address administration. The suggestion to keep
the database server address in a local file is intended to provide improved connection performance, but you should be
aware of the administrative workload that it requires.
TIP
If you object to the general IP address administration tasks required by using TCP/IP (independently from the DNS
issue), consider using DHCP to simplify the task of assigning and tracking IP addresses of each host on the network.
InterBase works in a DHCP environment as long as the client host has some means to resolve the IP address of the
server correctly at the time a client application requests an InterBase connection.
4. Database Properties
Changing database properties can give an improvement in performance without changing anything in the
design of your database. Applications require no change in their coding or design. Property changes are
transparent to the client and database design.
It is common for records to be larger than a single page. This means that InterBase fragments records and
stores them on multiple pages. Querying a given record requires multiple page reads from the database.
By increasing the size of a page, InterBase can reduce the number of multiple page reads and can store
record fragments more contiguously.
Indexes are B-trees of pointers to data pages containing instances of specific indexed values. If the index
B-tree is larger than one page, InterBase allocates additional database pages for the index tree. If the index
pages are larger, InterBase needs fewer additional pages to store the pointers. It is easier for the database
cache to store the entire B-tree in memory, and indexed lookups are much faster.
It is fairly likely for a query to request successive records in a table. For example, this is done during a table
scan, or query that returns or aggregates all records in a table. InterBase stores records on the first page
that is unused, rather than ensuring that they are stored near each other in the file. Doing a table scan
can potentially require retrieval of data by seeking all over the database. Seeks take time just as reading
data takes time.
Any given page can store records from only one table. This indicates that a larger page is certain to contain
more data from the same table, and therefore reading that page returns more relevant data.
InterBase allocates the database cache in number of pages, rather than a fixed number of bytes. Therefore
defining a larger page size increases the cache size. A larger cache is more likely to have a better hit rate
than a smaller cache.
InterBase performs a page read or write at the OS level by reading in 4096 byte increments regardless of
the size of the database page. Therefore, by defining the database with a page size of 4096, the database
I/O matches the low-level I/O and this results in greater efficiency when reading and writing pages.
Although 4KB seems to be the best page size for most databases, the optimal size depends on the structure
of the specific metadata and the way in which applications access the data. For this reason, you should
not consider the 4KB page size guideline to be a magic value. Instead, you should perform testing with
your application and database under several different page sizes to analyze which configuration gives the
best performance.
See Configuring the Database Cache for details about server cache settings.
The ibserver process running on an InterBase server maintains a cache in memory of recently used data
and index pages. Like any cache, it depends on repeated use of data on a given page to help speed up
subsequent access. In InterBase SuperServer implementations, the cache is shared by all clients connected
to the database.
By default, InterBase allocates enough memory for 2048 pages per database. If the page size of the current
database is 4KB, then ibserver uses 8MB of memory. If the page size is 8KB, then ibserver uses 16MB of
RAM for cache. The InterBase API provides a method for any individual client to request that the size of
the cache be higher. You can set a property on an individual database that establishes a different default
cache size when any client connects to that database:
The default of 2048 assumes that the server has a sufficient memory configuration to allocate for 8MB of
RAM per database. If memory is less plentiful on your server, or you have many databases that require
simultaneous access, you might need to reduce the default number of cache buffers.
It is highly recommended to increase the cache size for a database if you have enough memory to ac-
commodate it. Consider the following points:
• It is not useful to raise the cache size so high that the memory used by ibserver starts to page into
virtual memory. That defeats the benefit of caching data from disk in memory.
• It is not useful to raise the cache size higher than the number of pages in the database (which you
can view with View Database Statistics in IBConsole, or with the gstat command-line program). There
is no benefit to this, since any given page from disk occupies only one page in the cache, and is not
duplicated.
• One block of memory is allocated for cache per database. If a client connects to two separate databas-
es on one server, the ibserver process maintains two separate cache areas of memory. For example,
if database1.ib has a default cache size of 8000 pages of 4KB each, and database2.ib has a default
cache size of 10,000 pages of 2KB each, then while both databases have at least one connection,
ibserver allocates a total of 32MB + 20MB of RAM.
You should experiment with larger cache sizes and analyze the performance improvements. At some point,
you will observe diminishing returns. A typical application can achieve up to 30% performance increase
from proper cache sizing.
By contrast, a write-back cache defers flushing of the contents of a given cache page until a later time.
InterBase performs multiple writes to a cache page in RAM before it writes the page out to disk. This results
in better response time for the majority of write operations. Write-back cache consolidates I/O efficiently,
and therefore it is much faster than write-through cache.
InterBase offers write-back cache as the default on UNIX and Linux, and as an option on Windows platforms.
You can configure this at the database level using gfix -write async or by disabling forced writes for the
database in IBConsole (Database Properties|General tab|Options).
The real benefit of using asynchronous writes (write-back cache) is about four times performance in the
typical case. Some users have reported up to 20 times performance improvement from configuring asyn-
chronous writes, in applications that make heavy use of write operations (INSERT, UPDATE, DELETE). The more
writing an application does to the database—including write operations spawned by triggers—the more
benefit the application gains.
The risk of asynchronous writes is that data in cache might be lost if the server has a power loss, or if
ibserver exits abnormally for any reason. Write-through cache protects against data loss, at some perfor-
mance cost. If you test your server host and client/server application thoroughly and they are not suscep-
tible to crashes, then it is highly recommended to use asynchronous writes.
TIP
Use an uninterruptible power supply (UPS) to help protect your server against sudden power loss. A modest UPS is
inexpensive relative to the cost of losing your data, and easy to install. This can allow you to gain the benefits of the
asynchronous I/O mode in safety.
5.1. Defining Indexes
Proper use of indexes is an important factor in database performance. Effective policies for defining and
maintaining indexes can be the key to a very high performance client/server system. The self-tuning nature
of indexes in InterBase greatly benefits performance, but you can gain some additional benefit by periodic
maintenance tasks.
5.1.1. What is an Index?
An index in InterBase is a Balanced-Tree data structure stored inside the database file that provides a quick
lookup mechanism for the location of specific values in a table. Queries make use of appropriate indexes
automatically by means of the cost-based optimizer, which analyzes the tables and columns used in a
given query and chooses indexes that speed up the searching, sorting, or joining operations.
Defining indexes for some columns is part of designing a production database. Indexes dramatically im-
prove performance of SELECT queries. The greater the number of rows in the table, the greater the benefit
of using an index. Intelligently analyzing your database and defining indexes appropriately always improves
performance.
Indexes incur a small cost to maintain the index B-tree data structure during INSERT and UPDATE operations.
Because of this cost, it is not recommended to be overly liberal with index definitions. Do not create
redundant indexes, and do not make an index on every column as a substitute for database usage analysis.
You should not define an index for columns that have few distinct data values. For example, a column
FISCAL_QUARTER might have only four distinct values over a potentially very large data set. An index does
not provide much benefit for retrieval of data with this kind of distribution of values, and the work required
to maintain the index tree might outweigh the benefits.
In general, you should define indexes on all columns that you use in JOIN criteria or as sorting keys in an
ORDER BY clause. You do not have to define indexes on primary or foreign key columns, because these
table constraints implicitly create indexes.
5.1.4. Directional Indexes
Indexes are defined as either ASCENDING or DESCENDING. To sort in both directions, you need one index of
each type. This is also very important if you are using a scrolling list in a Delphi form, or when using the
TTable.Last method.
5.2. Normalizing Databases
Design your database with proper normalization of data. Records that have lots of repeating groups of
fields are larger than they need to be. Large records can increase the cost of sorting, and also cause
records to span more pages than is necessary, resulting in more page fragmentation and needlessly large
databases.
Denormalized table design can be more convenient for some types of client applications. You can use
InterBase views and stored procedures to in effect store a denormalized query on the server, for convenient
access from client applications. Meanwhile, the physical storage of the data is kept in a more efficient,
normalized form.
See the Data Definition Guide for details on views and stored procedures.
Blobs are a special case because there is a special Blob page type, on which other data types cannot be
stored. The data page for a record containing a Blob stores a Blob ID, which indicates which Blob page
the Blob is stored on. A Blob is stored on the same page as the primary record version, if it fits. If it does
not fit on that page, special pages are allocated for the Blob–as many as are required–and an index is
stored on the primary page. Blob pages are never shared; either a Blob is on a normal data page, or it
has a page to itself.
It is advantageous to define a Blob with a segment size equal to the page size. If both the page size and
the Blob segment size are 4096 bytes, queries of large Blobs can achieve a data transfer rate of up to
20MB per second. InterBase ceases to be any kind of bottleneck in this situation; it is more likely that the
hardware I/O bus, the network bandwidth, or the middleware are the limiting factors for throughput.
6.1. Tuning Indexes
Periodic maintenance of indexes can improve their performance benefit. You can write SQL scripts to
automate these tasks. See Using SQL Scripts.
6.1.1. Rebuilding Indexes
Periodically, a B-tree data structure might become imbalanced, or it might have some values in the tree
that have been deleted from the database (this should not happen in InterBase versions later than 5, due
to index garbage collection).
You should periodically rebuild indexes by turning them off and on:
You should recalculate the index selectivity if a change to the table affects the average distribution of data
values. InterBase calculates index selectivity automatically only when an index is created or activated, or
under user request using SET STATISTICS INDEX <index_name>. Bulk data updates on the underlying table
can put an index selectivity value out of sync with reality.
The ris.sql SQL script helps users recompute index selectivity on demand for various sets of indices via
the stored procedure COMPUTE_INDEX_SELECTIVITY which recomputes index selectivity for a given range
of indices. You can find ris.sql on %ProgramData%\Embarcadero\InterBase\gds_db\examples. The stored
procedure accepts the following parameters:
Run the following as SYSDSO user if you want to reset selectivity on RDB$ENCRYPTIONS indices.
entity_name - Name of the table or index. If you are not using quoted identifier names, make sure you
provide the entity name in upper case ASCII. This should be NULL if the index_scope specified is database-
wide ('DATABASE', or, 'SYSTEM')
Make sure you execute a COMMIT after executing the stored procedure.
Limitations
• You need to have database ownership/sysdba rights to execute this procedure for the whole database.
• Since the stored procedure uses EXECUTE STATEMENT, this script can only be used with InterBase XE
or later versions.
Examples
• Recompute selectivity for a particular table. This is useful when a particular table has undergone bulk
data insert/update/delete operation.
TIP
Create a SQL script with all the ALTER INDEX statements necessary to activate your indexes, and keep that handy. Use
it like a batch file with isql-i script.sql to help automate this procedure. You can create this script with this query:
You can get the database up and restored more quickly, and then activate indexes afterwards. The data is
accessible even if the indexes are inactive, but it is slower to query the tables.
Design your client applications to explicitly start and COMMIT transactions promptly, to reduce the number
of outstanding transactions.
See Overview of Sweeping for more details on sweeping, garbage collection, and the database snapshot.
In the InterBase server engine, a snapshot is generated by making a copy of the state of all other trans-
actions in the database. This snapshot is static for the current transaction. This means that any data com-
mitted to the database after the snapshot is created is not visible to operations using that snapshot. This
is the repeatable read transaction mode. Two identical queries made at different times are guaranteed to
get the same result set, even if other clients are updating data in the database.
Starting a transaction and making a snapshot data structure for the new transaction incurs some amount
of overhead. This overhead is magnified when using automatic transaction-handling, because the typical
automatic transaction behavior is to start a new transaction and commit it for every statement executed
against the database.
A correlated subquery is one in which the conditions of the subquery are different for each row in the
parent query, because they depend on values that y from row to row. InterBase executes the subquery
many times, once for each row in the parent query. Evaluating each row has a large cost in performance
relative to a non-correlated subquery. InterBase optimizes non-correlated subqueries out of the loop,
executes once, and uses the result as a fixed dataset.
Example as join:
SELECT D.*
FROM DEPARTMENT D JOIN EMPLOYEE E
ON D.MNGR_NO = E.EMP_NO WHERE E.JOB_COUNTRY = 'England'
InterBase optimizer executes a non-correlated subquery once, and uses the result set as many times as
necessary in the parent query.
Sometimes a correlated subquery is necessary, given the semantics of the SQL language. However, these
types of queries should be used with care and with the understanding that their performance is geometric
in relation to the size of the dataset on which they operate.
With parameterized queries, you can prepare a statement, but defer supplying the specific values for
certain elements of the query.
InterBase supports parameterized queries in DSQL, for cases when a given statement is to be executed
multiple times with different values. For example, loading a table with data might require a series of INSERT
statements with values for each record inserted. Executing parameterized queries has a direct performance
benefit, because the InterBase engine keeps the internal representation and optimization of the query
after preparing it once.
1. Place a named parameter in the statement with the Delphi :PARAMETER syntax. in place of a constant
value in a query. InterBase supports parameters in place constants. Tables and column names cannot
be parameterized.
2. Prepare the statement. Use the TQuery method Prepare. Delphi automatically prepares a query if it is
executed without first being prepared. After execution, Delphi unprepares the query. When a query
will be executed a number of times, an application should always explicitly prepare the query to avoid
multiple and unnecessary prepares and unprepares.
3. Specify parameters. For example, with the TQuery component, use the ParamByName method to supply
values for each parameter in the query.
4. Execute the statement. SELECT statements should use the Open method of TQuery. INSERT, UPDATE,
and DELETE statements should use the ExecSQL method. These methods prepares the statement in
SQL property for execution if it has not already been prepared. To speed performance, an application
should ordinarily call Prepare before calling ExecSQL for the first time.
5. Repeat steps 3 and 4 as needed.
6. Unprepare the query.
In some real-world cases involving repetitive operations, using parameterized queries has increased per-
formance 100%.
• Assigning indexes
• Combining indexes
• Determining join order
• Generating rivers
• Cost estimation
• Sort merges
InterBase supports syntax with the SELECT expression in embedded SQL and DSQL to allow the user to
specify the PLAN for a query. The syntax also works with SELECT statements in the body of a view, a stored
procedure, or a trigger.
It is beyond the scope of this chapter to describe in detail the syntax of the PLAN clause for specifying
the execution plan, or techniques for analyzing queries manually. The section on SELECT in the Language
Reference includes some examples of using PLAN.
To minimize the performance hit during INSERT or UPDATE operations, consider temporarily disabling
indexes during high-volume INSERT operations. Make sure to re-enable the indexes afterwards. This ap-
proach only requires the indexes to rebalance once for all the inserted data.
For more information on IBX refer to Getting Started with InterBase Express
IB Objects
Visual Components
This section describes visual components that developers commonly use in Delphi and C++Builder to
access data from InterBase. Follow the recommendations below for better client/server performance.
In a client/server configuration, a “fetch-all” is the nadir of performance, because it forces BDE to request
that the database generate a dataset again and send it over the network.
InterBase and most relational databases do not keep datasets in cache on the server in case the client
requests a refresh. InterBase must execute the SQL query again when the BDE requests a refresh. If the
query involves a large quantity of data, or complex joining or sorting operations, it is likely to take a long
time to generate the dataset.
It is also costly for the server to transfer a large dataset across a network interface. It is more costly by far
than it is for a desktop database like Paradox to return a dataset, because a desktop database typically
runs locally to the application
It is often the case that software developers choose to use a relational database like InterBase because
they are managing a larger amount of data than a desktop database like Paradox can handle efficiently.
Naturally, larger datasets take more time to generate and to send over a network.
The person using the client application perceives that it has better performance if the user does not have
to wait for refreshes. The less often the client application requests a refresh of the dataset, the better it
is for the user.
IMPORTANT
A principle of client/server application design is therefore to reduce the number of costly refresh operations as much
as possible.
TQuery
• CachedUpdates = False
• RequestLive = False
Setting RequestLive to False can prevent the VCL from keeping a client-side copy of rows; this has a benefit
to performance because it reduces the network bandwidth requirement
• Below are some operations in which a TQuery perform a fetch-all. Avoid these as much as possible,
or be aware of the cost of such operations.
It’s convenient to get the information on how many records are in a dataset, but when using InterBase,
calculation of the RecordCount itself forces a fetch-all. For this reason, referencing the RecordCount property
takes as much time as fetching the entire result dataset of the query.
A common use of RecordCount is to determine if the result set of an opened TQuery contains any records,
or if it contains zero records. If this is the case, you can determine this without performing a fetch-all by
testing for both EOF and BOF states. If both end of file and beginning of file are true for the dataset, then
no records are in the result set. These operations do not involve a fetch-all.
qryTest.Open;
if qryTest.BOF and qryTest.EOF then begin
// There are no result set records.
end
else begin
// There are some result set records.
end;
For the TQuery to filter records, it must request a much larger dataset than that which it subsequently
displays. The InterBase server can perform the filtering in a much more efficient manner before returning
the filtered dataset. You should use a WHERE clause in your SQL query. Even if you use a WHERE clause,
any use of the TQuery.Filter property still forces a fetch-all.
TTable
The TTable component is designed for use on relatively small tables in a local database, accessed in core
memory. TTable gathers information about the metadata of the table and tries to maintain a cache of the
dataset in memory. TTable refreshes its client-side copy of data when you issue the TTable.post method
and when you use the TDatabase.rollback method. This incurs a huge network overhead for client/server
databases, which tend to have larger datasets and are accessed over a network. You can observe the
activity of TTable with the SQL Monitor tool. This reports all calls to the BDE and InterBase API.
Though TTable is very convenient for its RAD Studio methods and its abstract data-aware model, you
should use it sparingly with InterBase or any other client/server database. TTable was not designed to be
used for client/server applications.
Migrating to InterBase
InterBase is a mature product that was originally architected before current standards came into existence.
As the standards evolved, it became clear that bringing InterBase into compliance with them would produce
a somewhat challenging migration path.
With the advent of InterBase 6, InterBase 6 introduced an increased compliance with the SQL-92 standard,
but migrating older (InterBase 5 and earlier) clients and databases might, in some cases, require consid-
erable attention to detail.
The feature areas affected are: the use of double quotes, which are now reserved for delimited identifiers;
the meaning of the DATE data type; the behavior of exact numeric data types, and the existence of new
keywords that might conflict with older metadata names.
This document describes how to plan and execute a smooth migration from earlier versions of InterBase
to InterBase 6 or later.
The earlier pages of this guide discuss the issues involved in the migration. Near the end, you will find
detailed, step-by-step instructions for both in-place migration and for migrating an old database to a new
one. See Migrating Servers and Databases,
1. Migration Process
These are the steps you must take to migrate servers, databases, and clients. Each is discussed in detail
in later sections:
Client Migration
2. Migration Issues
Before migrating your databases, you need to learn about InterBase SQL dialects and understand their
effect on servers, clients, and the use of certain features introduced in InterBase 6 and later.
• Double quote (“): changed from a synonym for the single quote (‘) to the delimiter for an object name.
• DECIMAL and NUMERIC data types with precision greater than 9: now stored as INT64 data types instead
of DOUBLE PRECISION.
• DATE, TIME, and TIMESTAMP data types: DATE has changed from a 64-bit quantity containing both
date and time information to a 32-bit quantity containing only date information. TIME is a 32-bit
quantity containing only time information, while TIMESTAMP is a 64-bit quantity containing both date
and time information (the same as DATE in pre-Version 6 SQL).
• Version 5 clients cannot access dialect 3 columns that are stored as INT64, TIME, or DATE. (DECIMAL
and NUMERIC columns with precision greater than 9 are stored as INT64.)
• Version 5 clients cannot display new data types in metadata using the SHOW command, or any
equivalent.
• Version 5 clients interpret the DATE data type as TIMESTAMP, since that was the definition of DATE
prior to InterBase 6.
• Version 5 clients cannot access any object named with a delimited identifiers.
If version 5 clients use any InterBase 6 or 7 keywords as object names, the InterBase 6 server permits this
without error because it recognizes that these clients were created at a time when these were not keywords.
Example: For example, the following statement uses the new keyword word TIME:
This statement, when executed via a pre-InterBase 6 client returns the information as it did in previous
versions. If this same query is issued using a version 6 or 7 client, an error is returned since TIME is now
a reserved word. See the New InterBase Keywords.
• Double quoted text is interpreted as a string literal. Delimited identifiers are not available.
• The DATE data type contains both time and date information and is interpreted as TIMESTAMP; the
name has changed but the meaning has not. Dialect 1 clients expect the entire timestamp to be
returned. In dialect 1, DATE and TIMESTAMP are identical.
• The TIME data type is not available.
• Dialect 1 databases store DECIMAL and NUMERIC data types with precision greater than 9 as DOUBLE
PRECISION, not INT64.
• Dialect 1 clients expect information stored DECIMAL and NUMERIC data types to be returned as double
precision; such clients cannot create database fields to hold 64-bit integers.
InterBase 6 and later servers recognize all the other InterBase features in dialect 1 clients and databases.
2.4.2. Dialect 2 Clients
Dialect 2 is available only on the client side. It is intended for assessing possible problems in legacy metadata
that is being migrated to dialect 3. To determine where the problem spots are when you migrate a database
from dialect 1 to dialect 3, you extract the metadata from the database, set isql to dialect 2, and then run
that metadata file through isql. isql issues warning whenever it encounters double quotes, DATE data
types, or large exact numerics to alert you to places where you might need to change the metadata in
order to make a successful migration to dialect 3.
To detect problem areas in the metadata of a database that you are migrating, extract the metadata and
run it through a dialect 2 client, which will report all instances of transition features. For example:
isql -i v5metadata.sql
• Dialect 3 clients expect DECIMAL and NUMERIC data types with precision greater than 9 to be returned
as INT64.
To learn how to migrate older data to INT64 storage, see Do you really need to migrate your NUMERIC
and DECIMAL Data Types? and Migrating NUMERIC and DECIMAL Data Types.
• On the command line, start isql with option -sql_dialectn, where <n> is 1, 2, or 3.
• Within an isql session or in a SQL script, you can issue this statement:
The following table shows the precedence for setting isql dialect:
In InterBase 6 and later, isql has the following behavior with respect to dialects:
• If you start isql and attach to a database without specifying a dialect, isql takes on the dialect of
the database.
• If you specify a dialect on the command line when you invoke isql, it retains that dialect after con-
nection unless explicitly changed.
• When you change the dialect during a session using SET SQL DIALECT <n>,
• When you create a database using isql, the database is created with the dialect of the isql client; for
example, if isql has been set to dialect 1, when you create a database, it is a dialect 1 database.
• If you create a database without first specifying a dialect for the isql client or attaching to a database,
isql creates the database in dialect 3.
The statements above are true whether you are running isql as a command-line utility or are accessing
it through IBConsole, InterBase new interface.
IMPORTANT
Any InterBase 6 and later isql client that attaches to a version 5 database resets to dialect 1.
• Start gpre with option -sql_dialectn. For example, this command sets gpre to dialect 3:
gpre -sql_dialect 3
EXEC SQL
SET SQL DIALECT n
EXEC SQL
SET SQL DIALECT n
See Migrating Databases to Dialect 3 for details about issues to consider before you issue the command.
IBConsole, InterBase graphical user interface, combines the functionality of the older Server Manager and
InterBase Windows isql. You now create and maintain databases, configure and maintain servers, and
execute interactive SQL from one integrated interface.
You can make InterBase 6 and later databases be read-only. This permits distribution on read-only media
such as CDROMs and reduces the chance of accidental or malicious changes to databases.
The ALTER COLUMN clause of the ALTER TABLE statement can change a name, data type, or position of a
column.
ALTER DOMAIN now includes the ability to change the name or data type of a domain definition.
The new EXTRACT() function extracts information from the new DATE, TIMESTAMP, and TIME data types.
In dialect 1, you can use it to extract information from the TIMESTAMP data type.
NOTE
DATE is new in the sense that it has a different meaning in dialect 3 databases than it did previously.
SQL Warnings
The InterBase API function set now returns warnings and informational messages along with error mes-
sages in the status vector.
InterBase now provides three new function libraries. The Services API, which is part of the InterBase client
library, provides functions for database maintenance tasks, software activation, requesting information
about the configuration of databases and server, and working with user entries in the security database.
In InterBase 6 and later, the functionality of gbak has been extended. gbak can now perform all of the
following actions:
IBX provides native Delphi components for InterBase data access, services, and installation. Embarcadero
C++Builder also can access IBX components.
Identifiers can now be keywords, contain spaces, be case sensitive, and contain non-ASCII characters. Such
identifiers must be delimited by double quotes. String constants must be delimited by single quotes.
In dialect 3 databases, data stored in DECIMAL and NUMERIC columns is stored as INT64 when the pre-
cision is greater than 9. This is true only for columns that are created in dialect 3. These same data types
are stored as DOUBLE PRECISION in dialect 1 and in all older InterBase versions. This change in storage
also requires different arithmetic algorithms.
In dialect 3, the DATE data type holds only date information. This is a change from earlier InterBase versions
in which it stored the whole timestamp.
Dialect 3 allows the use of the TIME data type, which only holds the time portion of the timestamp.
3.4.3. InterBase Keywords
These keywords are reserved words in all dialects.
• Beginning with InterBase 6, you cannot create objects in a dialect 1 database that have any of these
keywords as object names (identifiers).
• You can migrate a version 5 database that contains these keywords used as identifiers to version 6 or
later dialect 1 without changing the object names: a column could be named “YEAR”, for instance.
• Version 5 clients can access these keyword identifiers without error.
• Version 6 and later clients cannot access keywords that are used as identifiers. In a dialect 1 database,
you must change the names so that they are not keywords.
• If you migrate directly to dialect 3, you can retain the names, but you must delimit them with double
quotes. To retain accessibility for older clients, put the names in all upper case. Delimited identifiers
are case sensitive.
• Although TIME is a reserved word in version 6 and later dialect 1, you cannot use it as a data type
because such databases guarantee data type compatibility with version 5 clients.
• In dialect 3 databases and clients, any reserved word can be used as an identifier as long as it is
delimited with double quotes.
A
ACTION ACTIVE ADD ADMIN
B
BASED BASENAME BASE_NAME BEFORE
BOOLEAN BUFFER BY
C
CACHE CASCADE CASE CAST
CURSOR
D
DATABASE DATE DAY DB_KEY
DOUBLE DROP
E
ECHO EDIT ELSE ENCRYPT
F
FALSE FETCH FILE FILTER
G
GDSCODE GENERATOR GEN_ID GLOBAL
GROUP_COMMIT_WAIT_TIME
H
HAVING HELP HOUR
I
IF IMMEDIATE IN INACTIVE
ISQL
J
JOIN
K
KEY
L
LC_MESSAGES LC_TYPE LEFT LENGTH
M
MANUAL MAX MAXIMUM MAXIMUM_SEGMENT
N
NAMES NATIONAL NATURAL NCHAR
O
OCTET_LENGTH OF ON ONLY
P
PAGE PAGELENGTH PAGES PAGE_SIZE
PRIVILEGES PUBLIC
Q
QUIT
R
RAW_PARTITIONS RDB$DB_KEY READ REAL
RUNTIME
S
SCHEMA SECOND SEGMENT SELECT
T
TABLE TEMPORARY TERMINATOR THEN
U
UNCOMMITTED UNION UNIQUE UNKNOWN
V
VALUE VALUES VARCHAR VARIABLE
W
WAIT WEEKDAY WHEN WHENEVER
WRITE
Y
YEAR YEARDAY
NOTE
The following keywords are specific to InterBase and are not part of the SQL standard.
WEEKDAY YEARDAY
3.4.4. Delimited Identifiers
To increase compliance with the SQL 92 standard, InterBase 6 and later introduces delimited identifiers.
An identifier is the name of any database object; for instance a table, a column, or a trigger. A delimited
identifier is an identifier that is enclosed in double quotes. Because the quotes delimit the boundaries of
the name, the possibilities for object names are greatly expanded from previous versions of InterBase.
Object names can now:
• mimic keywords
• include spaces (except trailing spaces)
• be case sensitive
Up to and including version 5, InterBase allowed the use of either single or double quotes around string
constants. The concept of delimited identifiers did not exist. Beginning with InterBase 6 (dialect 3), anything
in single quotes is interpreted as a string constant and anything in double quotes is interpreted as a
delimited identifier. Here is the summary:
• In all versions of InterBase, anything inside single quotes is treated as a string constant.
• In InterBase version 5 and older, anything within double quotes is treated as a string constant, because
those versions do not have the concept of a delimited identifier.
• Version 6 dialect 1 is a transition mode that behaves like older versions of InterBase with respect to
quote marks: it interprets strings within either single or double quotes as string constants.
• Beginning with version 6 dialect 3, InterBase interprets anything inside double quotes as a delimited
identifier. Anything inside single quotes is interpreted as a string constant.
• When InterBase servers version 6 or later detect that the client is dialect 1, they permit client DML
(data manipulation) statements to contain double quotes and they correctly handle these as string
constants. However, they do not permit double quotes in client DDL (data definition) statements be-
cause that metadata would not be allowed in dialect 3. Version 6 servers all insist that string constants
be delimited with single quotes when clients create new metadata.
Columns and domains that are defined as DATE data type in InterBase 5 DATE appear as TIMESTAMP
columns when the database is restored in InterBase 6. However, a TIMESTAMP data type has four decimal
points of precision, while a Version 5 DATE data type has only two decimal points of precision.
If you migrate your database to dialect 3 and you require only date or only time information from a
TIMESTAMP column, you can use ALTER COLUMN to change the data type to DATE or TIME. These
columns each take only four bytes, whereas TIMESTAMP and the InterBase 5 DATE columns each take
eight bytes. If your TIMESTAMP column holds both date and time information, you cannot change it to
an InterBase 6 and later DATE or TIME column using ALTER COLUMN, because ALTER COLUMN does not
permit data loss. Dialect use also enforces certain rules:
• In dialect 1, only TIMESTAMP is available. TIMESTAMP is the equivalent of the DATE data type in
previous versions. When you back up an older database and restore it in version 6 and later, all the
DATE columns and domains are automatically restored as TIMESTAMP. DATE and TIMESTAMP data
types are both available and both mean the same thing in dialect 1.
• In dialect 3, TIMESTAMP functions as in dialect 1, but two additional data types are available: DATE
and TIME. These data types function as their names suggest: DATE holds only date information and
TIME holds only time.
• In dialect 3, DATE and TIME columns require only four bytes of storage, while TIMESTAMP columns
require eight bytes.
The following example shows the differences between dialect 1 and dialect 3 clients when date information
is involved.
In dialect 1 :
FLD1
===========
25-JUN-1999
In dialect 3 :
FLD1
=========================
1999-06-25 10:24:35.0000
In dialect 1 :
======
25-JU
Once you have migrated a database to dialect 3, any columns that previously had the DATE data type will
have the TIMESTAMP data type. If you want to store that data in a DATE or TIME column, follow these steps:
InterBase 6 and later dialect 3 no longer allow the use of the CAST operator to remove the date portion
of a timestamp by casting the timestamp value to a character value. When you cast a TIMESTAMP to a
CHAR or CHAR in dialect 3, the destination type must be at least 24 characters in length or InterBase will
report a string overflow exception. This is required by the SQL3 standard.
You can use the CAST() function in SELECT statements to translate between date/time data types and various
character-based data types. The character data type must be at least 24 characters in length. You can,
however, cast a TIMESTAMP to a DATE and then cast the DATE to a CHAR of less than 24 characters.
For example:
It is not possible to cast a date/time data type to or from BLOB, SMALLINT, INTEGER, FLOAT, DOUBLE
PRECISION, NUMERIC, or DECIMAL data types.
For more information, refer to “Using CAST() to convert dates and times” in the Embedded SQL Guide.
The table below outlines the results of casting to date/time data types:
Cast From To
TIMESTAMP DATE TIME
CHAR(<n>) String must be in format See below. String must be in for-
mat
CHARACTER(<n>) YYYY-MM-DD HH:MM:SS.thousands
HH:MM:SS.thousands
CSTRING(<n>)
TIMESTAMP Always succeeds Date portion of Time portion of times-
timestamp tamp
DATE Always succeeds; time portion of timestamp set to Always succeeds Error
0:0:0.0000
TIME Always succeeds; date portion of timestamp set to Error Always succeeds
current date
Casting DATE to string results in YYYY-MM-DD where “MM” is a two-digit month. If the result does not
fit in the string variable, a string truncation exception is raised. In earlier versions, this case results in DD-
Mon-YYYY HH:mm:SS.hundreds where “Mon” was a 3-letter English month abbreviation. Inability to fit in
the string variable resulted in a silent truncation.
In all of the forms above, you can substitute a month name or 3-letter abbreviation in English for the 2-
digit numeric month. However, the order must always be 4-digit year, then month, then day.
In previous versions of InterBase, you could enter date strings in a number of forms, including ones that had
only two digits for the year. Those forms are still available in InterBase 6 and later. If you enter a date with
only two digits for the year, InterBase uses its “sliding window” algorithm to assign a century to the years.
The following forms were available in earlier versions of InterBase and are still permitted in InterBase 6
and later:
If you write out the month name in English or use a three-character English abbreviation, you can enter
either the month or the day first. In the following examples, “xxx” stands for either a whole month name
or a three-letter abbreviation. All of the following forms are acceptable:
For example, the following INSERT statements all insert the date “January 22, 1943”:
The following statement would enter the date “January 22, 2043”:
The table below outlines the results of casting from date/time data types:
The following table shows the result of adding and subtracting DATE, TIME, TIMESTAMP, and numeric
values. “Numeric value” refers to any value that can be cast as an exact numeric value by the database
engine (for example, INTEGER, DECIMAL, or NUMERIC).
NOTE
Numeric value + DATE, TIME, or TIMESTAMP is symmetric to DATE, TIME, or TIMESTAMP + numeric value.
You can use the date/time data types with the MIN(), MAX(), COUNT() functions, the DISTINCT argument to
those functions, and the GROUP BY argument to the SELECT() function. An attempt to use SUM() or AVG()
with date/time data types returns an error.
Default Clauses
CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP can be specified as the default clause for
a domain or column definition.
The EXTRACT() function extracts date and time information from databases. In dialect 3, the EXTRACT
operator allows you to return different parts of a TIMESTAMP value. The EXTRACT operator makes no
distinction between dialects when formatting or returning the information. EXTRACT() has the following
syntax:
The value passed to the EXTRACT() expression must be DATE, TIME, or TIMESTAMP. Extracting a part that
doesn’t exist in a data type results in an error. For example:
The data type of EXTRACT() expressions depends on the specific part being extracted:
The most notable migration issues involve using the division operator and the AVG() function (which also
implies division) with exact numeric operands. Exact numeric refers to any of the following data types: IN-
TEGER, SMALLINT, DECIMAL, NUMERIC. NUMERIC and DECIMAL data types that have a precision greater
than 9 are called “large exact numerics” in this discussion. Large exact numerics are stored as DOUBLE
PRECISION in dialect 1 and as INT64 in columns created in dialect 3.
IMPORTANT
When you migrate an exact numeric column to dialect 3 it is still stored as DOUBLE PRECISION. The migration does
not change the way the data is stored because INT64 cannot store the whole range that DOUBLE PRECISION can store.
There is potential data loss, so InterBase does not permit direct conversion. If you decide that you want your data stored
as INT64, you must create a new column and copy the data. Only exact numeric columns that are created in dialect 3
are stored as INT64. The details of the process are provided in Migrating Databases to Dialect 3.
You might or might not want to change exact numeric columns to INT64 when you migrate to dialect 3.
See Do you really need to migrate your NUMERIC and DECIMAL Data Types? for a discussion of issues.
Operations involving division return an exact numeric if both operands are exact numerics in dialect 3.
When the same operation is performed in dialect 1, the result is a DOUBLE PRECISION.
To obtain a DOUBLE PRECISION quotient of two exact numeric operands in dialect 3, explicitly cast one of
the operands to DOUBLE PRECISION before performing the division:
Similarly, to obtain a double precision value when averaging an exact numeric column, you must cast the
argument to double precision before the average is calculated:
3.4.7. Compiled Objects
The behavior of a compiled object such as a stored procedure, trigger, check constraint, or default value
depends on the dialect setting of the client at the time the object is compiled. Once compiled and validated
by the server the object is stored as part of the database and its behavior is constant regardless of the
dialect of the client that calls it.
EXECUTE PROCEDURE exact 1 returns 1 when executed by either a dialect 1 or dialect 3 client.
EXECUTE PROCEDURE exact 1 returns 0 when executed by either a dialect 1 or dialect 3 client.
EXECUTE PROCEDUREbignum (65535, 65535) returns –131071.0000 when executed by either a dialect 1
or dialect 3 client.
EXECUTE PROCEDUREbignum (65535, 65535) returns *ERROR* can’t access INT64 when executed by a
dialect 1 client.
EXECUTE PROCEDUREbignum (65535, 65535) returns 4294836225 when executed by a dialect 3 client.
3.4.8. Generators
InterBase 6 and later generators return a 64-bit value, and only wrap around after 264 invocations (assuming
an increment of 1), rather than after 232 as in InterBase 5. Applications should use an ISC_INT64 variable
to hold the value returned by a generator. A client using dialect 1 receives only the least significant 32
bits of the updated generator value, but the entire 64-bit value is incremented by the engine even when
returning a 32-bit value to a client that uses dialect 1. If your database was using an INTEGER field for
holding generator values, you need to recreate the field so that it can hold 64-bit integer values.
3.4.9. Miscellaneous Issues
• IN clauses have a limit of 1500 elements
Resolution If you have more than 1500 elements, place the values in a temporary table and use a SELECT
subquery in place of the list elements.
• Using isql to select from a TIMESTAMP column displays all information when client dialect is 3.
Resolution In versions of InterBase prior to 6.0, the time portion of a timestamp displayed only if SET TIME
ON was in effect. In 6.0 and later client dialect 3, the time portion of the timestamp always displays.
• Older clients can still access databases that have been migrated to InterBase 6 and later. You must
be aware, however, that they cannot access new data types or data stored as INT64, and they always
handle double quoted material as strings.
• InterBase strongly recommends that you establish a migration testbed to check your migration pro-
cedures before migrating production servers and databases. The testbed does not need to be on the
same platform as the production clients and servers that you are migrating.
The migration path varies somewhat depending on whether you are replacing an existing server or in-
stalling a new server and moving old databases there. Upgrading an existing server costs less in money,
but may cost more in time and effort. The server and all the databases you migrate with it are unavailable
during the upgrade. If you have hardware available for a new InterBase 6 and later server, the migration
can be done in parallel, without interrupting service more than very briefly. This option also offers an easier
return path if problems arise with the migration.
1. Shut down each database before backup to ensure that no transactions are in progress.
2. Back up all databases on the version 5 server. Include isc4.ib if you want to preserve your configured
user IDs.
As a precaution, you should validate your databases before backing up and then restore each database
to ensure that the backup file is valid.
3. Shut down the version 5 server. If your current server is a Superserver, you are not required to uninstall
the server if you intend to install over it, although uninstalling is always good practice. You cannot
have multiple versions of InterBase on the same machine. If your current server is Classic, you must
uninstall before installing InterBase 6.
4. Install the version 6 server.
NOTE
Note that InterBase can run only as user “root” or user “InterBase” on UNIX.
After performing these steps, you have an InterBase 6 and later server and InterBase 6 and later, dialect 1
databases. See About InterBase 6 and Later, Dialect 1 Databases to understand more about these databas-
es. See Migrating Databases to Dialect 3 for a description of how to migrate databases to dialect 3. See
Migrating Clients for an introduction to client migration.
In the following steps, older refers to databases that are on a version 5 or older InterBase server. Newer
and new refer to an InterBase version 6 or newer server.
1. Shut down the older databases before backup to ensure that no transactions are in progress.
2. Back up all databases that are on the older server. Include isc4.ib if you want to preserve your
configured user IDs.
Note that InterBase can run only as user “root” or user “InterBase” on UNIX.
5. Copy the database backup files to the new server and restore each database from its backup file. This
process creates databases that have the current version, ODS, and dialect. (Note: In later versions of
InterBase, it creates the appropriate current ODS, but always dialect 1.)
After performing these steps, you have an InterBase 6 and later server and InterBase 6 and later, dialect 1
databases. See About InterBase 6 and Later, Dialect 1 Databases to understand more about these databas-
es. See Migrating Databases to Dialect 3 for a description of how to migrate databases to dialect 3. See
Migrating Clients for an introduction to client migration.
• A version 5 client can access everything in the database with no further changes.
• If there are object names – column or table names, for instance – that include any of the 17 new
keywords, you must change these names in order to access these objects with a version 6 dialect 1
client. The new ALTER COLUMN clause of ALTER TABLE makes it easy to implement column name changes.
• Version 5 clients can still access the columns.
• Dialect 3 clients can access these columns as long as they delimit them with double quotes.
• The 17 new keywords are reserved words. However, the new data types TIME and DATE are not
available to use as data types. DATE columns have the old meaning—both date and time. The new
meaning of DATE – date only – is available only in dialect 3.
• All columns that were previously DATE data type are now TIMESTAMP data type. TIMESTAMP contains
exactly the information that DATE did in previous versions.
• Exact numeric columns – those that have a DECIMAL or NUMERIC data type with precision greater
than 9 – are still stored as DOUBLE PRECISION data types. All arithmetic algorithms that worked before
on these columns still work as before. It is not possible to store data as INT64 in dialect 1.
• Double quotes
• The DATE data type
• Large exact numerics (for purposes of this discussion, NUMERIC and DECIMAL data types that have
a precision greater than 9)
• Keywords
The process varies somewhat depending on whether you can create an application to move data from
your original database to an empty dialect 3 database. If you do not have access to such a utility, you need
to perform an in-place migration of the original database.
4.4.1. Overview
In either method, you begin by extracting the metadata from your database, examining it for problem
areas, and fixing the problems.
• If you are performing an in-place migration, you copy corrected SQL statements from the metadata
file into a new script file, modify them, and run the script against the original database. Then you set
the database to dialect 3. There are some final steps to take in the dialect 3 database to store old
data as INT64.
• If you have a utility for moving data from the old database to a newly created empty database, you
use the modified metadata file to create a new dialect 3 database and use the utility to transfer data
from the old database to the new.
In both cases, you must make changes to the new database to accommodate migrated columns that must
be stored as INT64 and column constraints and defaults that originally contained double quotes.
NOTE
You could also proceed by removing unchanged SQL statements from the original metadata file, but this is more likely
to result in problems from statements that were left in error. Embarcadero recommends creating a new script file that
contains only the statements that need to be run against the original database.
For the remaining steps, use a text editor to examine and modify the metadata and script files. Place copied
statements into the new script file in the same order they occur in the metadata file to avoid dependency
errors.
4. Search for each instance of double quotes in the extracted metadata file. These can occur in trig-
gers, stored procedures, views, domains, table column defaults, and constraints. Change each dou-
ble quote that delimits a string to a single quote. Make a note of any tables that have column-level
constraints or column defaults in double quotes.
Copy each changed statement to your script file, but do not copy ALTER TABLE statements whose only
double quotes are in column-level constraints or column defaults.
IMPORTANT
When copying trigger or stored procedure code, be sure to include any associated SET TERM statements.
Quoted quotes
If there is any chance that you have single or double quotes inside of strings, you must search and replace
on a case-by-case basis to avoid inappropriate changes. The handling of quotation marks within strings
is as follows:
5. In the new script file, search for occurrences of the TIMESTAMP data type. In most cases, these were
DATE data types in your pre-6 database. For each one, decide whether you want it to be TIME,
TIMESTAMP, or DATE in your dialect 3 database. Change it as needed.
6. Repeat step 5 in the metadata file. Copy each changed statement to your new script file.
7. In the new script file, search for occurrences of reserved words that are used as object names and
enclose them in double quotes; that makes them delimited identifiers.
8. Repeat step 7 in the metadata file. Copy each changed statement to your new script file.
9. In each of the two files, search for each instance of a DECIMAL or NUMERIC data type with a precision
greater than 9. Consider whether or not you want data stored in that column or with that domain to
be stored as DOUBLE PRECISION or INT64. See Do you really need to migrate your NUMERIC and
DECIMAL Data Types? for a discussion of issues. For occurrences that should be stored as DOUBLE
PRECISION, change the data type to that. Leave occurrences that you want to be stored as INT64
alone for now. Copy each changed statement that occurs in the metadata file to your new script file.
10. Locate each CREATE TRIGGER and CREATE DOMAIN statement and change it to ALTER TRIGGER or ALTER
DOMAIN as appropriate.
11. Locate each CREATE VIEW statement. Precede it by a corresponding DROP statement. For example, if
you have a CREATE VIEW <foo> statement, put a DROP VIEW <foo> statement right before it, so that
when you run this script against your database, each view first gets dropped and then re-created.
12. If you have any ALTER TABLE statements that you copied because they contain named table-level
constraints, modify the statement so that it does nothing except drop the named constraint and then
add the constraint back with the single quotes.
13. Check that stored procedure statements are ALTER PROCEDURE statements. This should already be the
case.
14.At the beginning of the script, put a CONNECT statement that connects to the original database that
you are migrating.
15. Make sure your database is backed up and run your script against the database.
16. Use gfix to change the database dialect to 3.
NOTE
To run gfix against a database, you must attach as either the database owner or SYSDBA.
17. At this point, DECIMAL and NUMERIC columns with a precision greater than 9 are still stored as
DOUBLE PRECISION. To store the data as INT64, read Do you really need to migrate your NUMERIC
and DECIMAL Data Types? and, if necessary, follow the steps in Migrating NUMERIC and DECIMAL
Data Types.
18. Validate the database using either IBConsole or gfix.
That’s it. You have got a dialect 3 database. There is a little more work to do if you want your NUMERIC
and DECIMAL columns with a precision of greater than 9 to be stored as INT64. At this point, they are
still stored as DOUBLE PRECISION. To decide whether you want to change the way data is stored in these
columns, read Do you really need to migrate your NUMERIC and DECIMAL Data Types? and Migrating
NUMERIC and DECIMAL Data Types.
In addition, there are some optional steps you can take that are described in the following sections, Column
Defaults and Column Constraints and Unnamed Table Constraints.
IMPORTANT
If you ever extract metadata from the dialect 3 database that you created using the steps above, and if you plan to
use that metadata to create a new database, check to see if the extracted metadata contains double quotes delimiting
string constants in column defaults, column constraints, or unnamed table constraints. Change any such occurrences
to single quotes before using the metadata to create the new database.
Following the steps above creates a dialect 3 database that is fully functional, but if it contains double
quoted string constants in column defaults, column constraints, or unnamed column constraints, inconsis-
tencies are visible when you SHOW metadata or extract it. You can choose to resolve these inconsistencies
by following these steps:
3. For each affected column, use the ALTER COLUMN clause of the ALTER TABLE statement to give the
column a temporary name. If column position is likely to be an issue with any of your clients, change
the position as well.
4. Create a new column with the desired data type, giving it the original column name and position.
5. Use UPDATE to copy the data from old column to the new column:
UPDATE table_name
SET new_col = old_col;
To bring unnamed table constraints that contain double quotes into compliance with the dialect 3 standard,
follow these steps:
If SHOW TABLE shows that InterBase stores the unnamed constraint as “INTEG_2”, then issue the following
statement to change the constraint:
In InterBase 6 and later dialect 3, when you create a NUMERIC or DECIMAL column with a precision of
greater than 9, data in it is automatically stored as an INT64 exact numeric.
If you want NUMERIC and DECIMAL data types with a precision greater than 9 to be stored as exact
numerics, you must take some extra steps after migrating to dialect 3. The following sections tell you how
to decide whether you really need to take these steps and how to perform them if you decide you want
the exact numerics.
Do you really need to migrate your NUMERIC and DECIMAL Data Types?
As you migrate your databases to dialect 3, consider the following questions about columns defined with
NUMERIC and DECIMAL data types:
• Is the precision less than 10? If so, there is no issue. You can migrate without taking any action and
there will be no change in the database and no effect on clients.
• For NUMERIC and DECIMAL columns with precision greater than 9, is DOUBLE PRECISION an appro-
priate way to store your data?
• In many cases, the answer is “yes.” If you want to continue to store your data as DOUBLE PRECISION,
change the data type of the column to DOUBLE PRECISION either before or after migrating your
database to dialect 3. This does not change any functionality in dialect 3, but it brings the declaration
into line with the storage mode. In a dialect 3 database, newly-created columns of this type are stored
as INT64, but migrated columns are still stored as DOUBLE PRECISION. Changing the declaration
avoids confusion.
DOUBLE PRECISION may not be appropriate or desirable for financial applications and others that are
sensitive to rounding errors. In this case, you need to take steps to migrate your column so that it is stored
as INT64 in dialect 3. As you make this decision, remember that INT64 does not store the same range as
DOUBLE PRECISION. Check whether you will experience data loss and whether this is acceptable.
Read Do you really need to migrate your NUMERIC and DECIMAL Data Types? to decide whether you
have columns in a dialect 1 database that would be best stored as 64-bit integers in a dialect 3 database.
If this is the case, follow these steps for each column:
1. Migrate your database to InterBase 6 and later as described in Method One: In-place Migration.
2. Use the ALTER COLUMN clause of the ALTER DATABASE statement to change the name of each affected
column to something different from its original name. If column position is going to be an issue with
any of your clients, use ALTER COLUMN to change the positions as well.
3. Create a new column for each one that you are migrating. Use the original column names and if
necessary, positions. Declare each one as a DECIMAL or NUMERIC with precision greater than 9.
4. Use UPDATE to copy the data from each old column to its corresponding new column:
UPDATE tablename
SET new_col = old_col;
5. Check that your data has been successfully copied to the new columns and drop the old columns.
Overview Extract the metadata from your database, examine it for problem areas, and fix the problems.
Use the modified metadata file to create a new dialect 3 database and use an application to transfer data
from the old database to the new.
1. If you have not migrated the database to version 6, dialect 1, do so first. Back up the database again.
2. Extract the metadata from the database using isql. If you are migrating a database that contains data
structures created with GDML, see Migrating Older Databases.
For the following steps, use a text editor to examine and modify the metadata file.
3. Search for each occurrence of the TIMESTAMP data type. In most cases, these were DATE data types
in your pre-6 database. Decide whether you want it to be TIME, TIMESTAMP, or DATE in your dialect
3 database. Change it as needed.
4. Find all instances of reserved words that are used as object names and enclose them in double quotes
to make them delimited identifiers.
5. Search for each instance of double quotes in the extracted metadata file. These can occur in triggers,
stored procedures, views, domains, exceptions, table column defaults, and constraints. Change each
double quote to a single quote.
6. Search for each instance of a DECIMAL or NUMERIC data type with a precision greater than 9. Con-
sider whether or not you want that data stored as DOUBLE PRECISION or INT64. See Do you really
need to migrate your NUMERIC and DECIMAL Data Types? for a discussion of issues. For occurrences
that should be stored as DOUBLE PRECISION, change the data type to that. Leave occurrences that
you want stored as INT64 alone for now.
7. At the beginning of the file, enter SET SQL DIALECT 3. On the next line, uncomment the CREATE
DATABASE statement and edit it as necessary to create a new database.
1. Try extracting metadata as described in Step 2 on page Method One: In-place Migration and examine
it to see if all tables and other DDL structures are present. If they are not, delete the metadata file and
extract using the -a switch instead of the -x switch. This extracts objects created in GDML.
2. You may have to change some of the code to SQL form. For example, the following domain definition
no_init_flag missing);
4.5. Migrating Clients
It is good practice to recompile and relink the application and make note of field names, data type use,
and so on in the new application. When you recompile, state the dialect explicitly:
IMPORTANT
If you have databases that use any of the new 2020 keywords as object identifiers and you are not migrating those
databases to dialect 3, you might consider not migrating any older version clients. If you migrate them to 2020 dialect
1, you lose the ability to access those keyword columns. See InterBase Keywords.
When you recompile an existing gpre client, you must recompile it with the gpre -sql_dialect n switch.
There are several paths that allow you to create dialect 3 clients that access all new InterBase features:
-sql_dialect n
GPRE
• Issue the following command line option:
-sql_dialect n
BDE All applications use SQL dialect 1. To access InterBase dialect 3 features from Delphi,
use the IBX components.
InterClient InterBase 6: All applications use SQL dialect 1.
InterBase Limits
This appendix defines the limits of a number of InterBase characteristics. The values the following table lists
are design limits, and in most cases are further restricted by finite resource restrictions in the operating
system or computer hardware.
InterBase Specifications
Characteristic Value
Maximum number of clients There is no single number for the maximum number of clients the InterBase server can
connected to one server serve – it depends on a combination of factors including capability of the operating
system, limitations of the hardware, and the demands that each client puts on the serv-
er. Applications that engage in high levels of contention or that perform complex or
high-volume operations could cause the practical number of clients to be fewer. In ap-
plications that do not generate much contention, InterBase can support a large num-
ber of users, where “large” is not well-defined.
Maximum database size No limit is imposed by InterBase; maximum size is defined by the operating system.
This is a design parameter of InterBase, but most operating systems have a much low-
er limit on the number of files that a single process can have open simultaneously. In
some cases, the OS provides a means to raise this limit. Refer to your OS documenta-
tion for the default open files limit, and the means to raise this limit.
Maximum number of cache 750,000. Not all database page sizes will be able to accommodate this limit in a 32-bit
pages per database address space. When applying a large cache, other considerations must be taken into
account such as the number of connections, statements or other database using mem-
ory at the same time. A large cache size will depend on whether a 32-bit executable is
running on a 64-bit OS or how a 32-bit OS has been configured.
This number depends on system memory, OS, InterBase version and DB page size:
InterBase Specifications
Characteristic Value
• 1KB page size: largest table is 2TB
• 2KB page size: largest table is 4TB
• 4KB page size: largest table is 8TB
• 8KB page size: largest table is 16TB
• 16KB page size: largest table is 32TB
Maximum versions per table 255; then no more metadata changes until the database has been backed up and re-
stored.
Maximum row size 64KB. Each Blob and array contributes eight bytes to this limit in the form of their Blob
handle.
Systems tables (tables maintained by the InterBase engine for system data) have a row
size limit of 128KB.
Maximum number of rows and By design, 232 rows, because rows are enumerated with a 32-bit unsigned integer per
columns per table table. Number of columns in a row depends on data types used. One row can be 64K.
For example, you can define 16,384 columns of type INTEGER (four bytes each) in one
table.
Depends on row characteristics and compression, but as many rows as can be stored in
maximum table size. The highest row number is 2**38 - 1 (274,877,906,943).
Maximum number of indexes It is now possible to create 255 indexes on a single table in InterBase XEU1.
per table
A larger DB page size always enables more index definitions than smaller DB page
sizes. If your DB page size is not sufficient, you will receive the error “cannot add index,
index root page is full.”
Maximum number of indexes By design, 232, because you can create 216 tables per database, and each table can
per database have 216 indexes.
Because InterBase XE supports UTF8 and multiple other multi-byte character sets, the
limit has been increased. For example, a single-column key using 4-byte UTF8 charac-
ter would calculate to 1020/4 = 254 UTF8 characters with a 4KB page size.
• ODS 15 databases automatically allow index definitions where the underlying key
size is now a factor of the database page size. An index key can now be up to 4
bytes less than 1/4th the page size.
• By default, InterBase databases are created with a 4KB page size. This can be over-
ridden up to 16KB page size by the database developer.
• The 4KB page size database would allow indexes that can accommodate 1020
bytes per key.
• A 16KB page size can accommodate a 4092 bytes per key and so on.
Caution: Databases created with engines enabled with this functionality cannot be
moved back to older versions of InterBase.
Also a database restore to a smaller page size will fail if indexes with large key size can-
not fit within the limit specified above.
InterBase Specifications
Characteristic Value
No user interface or actions are required by the user to enable this functionality. Each
time a database restore is performed, the indices are recreated.
Only ODS 15 and later databases have support for larger index keys. If you want to use
this facility, restore your database to ODS 15. Other indices that use a smaller size than
252 bytes continue to have the same on-disk storage without any penalty.
Note that multibyte character sets must fit within the key by counting bytes, not by
counting characters.
It is good practice to keep index keys as small as possible. This limits the depth of in-
dexes and increases their efficiency.
Maximum number of events No restriction by design, but there is a practical limit, given that there is a limit on the
per stored procedure length of code in a stored procedure or trigger (see below).
Maximum stored procedure 48KB of BLR, the bytecode language compiled from stored procedure or trigger lan-
or trigger code size guage.
Maximum Blob size The size of the largest single Blob depends on the database page size:
1KB page size: largest Blob is 64MB
2KB page size: largest Blob is 512MB
4KB page size: largest Blob is 4GB
8KB page size: largest Blob is 32GB
16KB page size: largest Blob is 256GB
A Blob is a stream of many segments. The maximum Blob segment size is 64KB.
Maximum tables in a JOIN No restriction by design, but the task of joining tables is exponential in relation to
number of tables in the join.
The largest practical number of tables in a JOIN is about 16, but experiment with your
application and a realistic volume of data to find the most complex join that has ac-
ceptable performance.
Maximum levels of nested There is no restriction by design.
queries
The practical limit depends on the type of queries you nest. Experiment with your ap-
plication and a realistic volume of data to find the deepest nested query that has ac-
ceptable performance.
Maximum number of columns 16
per one composite index
Levels of nesting
per stored procedure or trigger • 750 on Windows platforms
• 1000 for UNIX platforms
Maximum size of key 32 KB
in SORT clause
Maximum size of external table 64-bit file offset allows up to 16 Exabytes of information.
file
Range of date values January 1, 100 a.d. to February 29, 32768 a.d.
Transaction Limits
• Databases with ODS <=15 need to be backed up and restored before they hit the
2 Billion transaction ID limit.
• Databases with ODS >=16 can continue to be online beyond 2 billion transactions
since they support 64-bit Transaction ID. A benefit of this is you can have your
databases online to service your applications more closer to a 24/7 scenario with-
out having to backup/restore due to this earlier 32-bit limit.
InterBase Specifications
Characteristic Value
Maximum number of generators
per database • The maximum number of generators in a database is 32,767. However, the num-
ber of user defined generators is lower because system tables use some generator
IDs for internal use from the same ID namespace.