Firebird Documentation Index → Firebird 1.0 Quick Start → Connecting to the sample database |
In the examples
subdirectory
of your Firebird installation is a sample database named
employee.gdb
. You can use this database to “try
your wings”.
If you are running the server on Windows XP or ME, be sure to
rename this test database to employee.
fdb
to get
around the System Restore utility, which targets files with a .gdb
extension. There is more information
about this problem in the Release Notes (look in the doc
subdir of your Firebird
installation).
If you move the sample database, be sure you move it to a hard disk that is physically attached to your server machine. Shares, mapped drives or (on Unix) mounted SMB (Samba) filesystems will not work. The same rule applies to any databases that you create.
There are two elements to a TCP/IP connection string: the server name and the disk/filesystem path. Its format is as follows:
For a Linux server:
servername:/filesystem-path/database-file
Example on a Linux or other Posix server named serverxyz
:
serverxyz:/opt/interbase/examples/employee.gdb
For a Windows server:
servername:DriveLetter:\filesystem-path\database-file
Windows example:
serverxyz:C:\Program Files\Firebird\examples\employee.gdb
Connecting to a Firebird database requires the user to
authenticate using a user name and a valid password. Any user other than
SYSDBA, root
(on Posix systems), or Administrator
(on Windows systems, if
Firebird runs as this user) needs also to have permissions to objects
inside a database. For simplicity here, we will look at authenticating
as SYSDBA using the password
masterkey
.
There are several different ways to connect to a database using
isql. One way is to start
isql in its interactive shell. Go to the
bin
subdirectory of your
Firebird installation and, at that prompt, type the command
isql (on Linux: ./isql) [↵ means
“hit Enter”]:
C:\Program Files\Firebird\bin>isql↵ Use CONNECT or CREATE DATABASE to specify a database SQL>CONNECT "C:\Program Files\Firebird\examples\employee.gdb"↵ CON>user 'SYSDBA' password 'masterkey';↵
In isql, every SQL statement
must end with a semicolon. If you hit Enter and
the line doesn't end with a semicolon, isql assumes that the
statement continues on the next line and the prompt will change
from SQL>
to CON>
. This
enables you to spread long statements over multiple lines. If
you hit Enter after your statement and you've
forgotten the semicolon, just type it on the empty line after
the CON>
prompt and press
Enter again.
If you run Classic Server on Linux, a fast, direct local
connection is attempted if the database path does not start with
a hostname. This may fail if your Linux login doesn't have
sufficient access rights to the database file. In that case,
connect to localhost
:/
<path>. Then the server
process (with Firebird 1.0 usually running as root
) will open the file. On the
other hand, network-style connections may fail if a user created
the database in Classic local mode and the server doesn't have
enough access rights.
Although single quote symbols are the “norm” for delimiting strings in Firebird, double quote symbols were used with the database path string in the above example. This is sometimes necessary with some of the command-line utilities where the path string contains spaces. Single quotes should work for paths that do not contain spaces.
The quotes around “SYSDBA” and “masterkey” are optional, by the way. Database paths without spaces also don't need to be quoted.
At this point, isql will inform you that you are connected:
DATABASE "C:\Program Files\Firebird\examples\employee.gdb", User: sysdba SQL>
You can now continue to play about with the
employee.gdb
database. The characters
isql stand for interactive SQL
[utility]. You can use it for querying data, getting
information about the metadata, creating database objects, running
data definition scripts and much more.
To get back to the command prompt type
SQL>QUIT;↵
For more information about isql, see Using Firebird, Chapter 10: Interactive SQL Utility (isql).
GUI client tools usually take charge of composing the CONNECT string for you, using server, path, user name and password information that you type into prompting fields. Use the elements as described in the preceding topic.
It is quite common for such tools to expect the entire server + path as a single string
Remember that file names and commands on Linux and other Posix command shells are case-sensitive
Firebird Documentation Index → Firebird 1.0 Quick Start → Connecting to the sample database |