1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
|
<html>
<head>
<title>SQL Relay - Getting Started With Interbase/Firebird</title>
<link rel="stylesheet" href="../css/styles.css">
</head>
<body>
<span class="heading1">Getting Started With Interbase/Firebird</span><br>
<ul>
<li><a href="#installation">Installation</a></li>
<ul>
<li><a href="#startingatboot">Starting the Database at Boot Time</a></li>
</ul>
<li><a href="#creating">Creating a Database</a></li>
<li><a href="#accessing">Accessing a Database</a></li>
<li><a href="#sqlrelay">Accessing a Database With SQL Relay</a></li>
<li><a href="#quirks">Interbase Quirks</a></li>
</ul>
<a name="installation"></a>
<span class="heading1">Installation</span><br>
<p>I've successfully installed Interbase 6.0.1 and Firebird 1.0.0, 1.0.2,
1.0.3, 1.5 and 1.5.2 on Linux. I've never tried to install them on any other
platform.</p>
<p>There are 2 versions of Interbase/Firebird: Classic Server (CS) and
Super Server (SS). Classic Server only allows a single connection while Super
Server allows multiple connections. I recommend using Super Server and this
document describes it's installation.</p>
<p>You can download source and binary distributions of Interbase 6.0.1 for
Linux or Solaris in tar.gz or RPM formats from the
<a href="http://www.borland.com">Borland web site</a>. Binary and source
distributions of Firebird in many different formats (including tar.gz and RPM)
for many different platforms are available at the
<a href="http://firebird.sourceforge.net">Firebird web site</a>.
<p>The tar.gz distributions come with an install script. The RPM distributions
can be installed using <i>rpm -i</i>.</p>
<p>Interbase distributions and Firebird distributions prior to version 1.5
create a directory called /opt/interbase. Firebird 1.5 creates
/opt/firebird.</p>
<p>Firebird 1.5 rpm's leave /opt/firebird owned by root, with -r-xr-xr-x
permissions. This is wrong and will cause the server not to start. Change
the permissions and ownership as follows (as root):</p>
<blockquote><b>
chmod 775 /opt/firebird<br>
chown firebird:firebird /opt/firebird
</b></blockquote>
<p>Firebird 1.5 requires libstdc++.so.5 but most Linux distributions ship with
a more recent version. If your system doesn't have /usr/lib/libstdc++.so.5
then you may need to install a compatibility library. On Fedora Core 4, you
need to install compat-libstdc++-33 as follows (as root):</p>
<blockquote><b>
yum install compat-libstdc++-33
</b></blockquote>
<span class="heading2">Install libncurses.so.4</span><br>
<p>Interbase 6.0.1 requires libncurses.so.4. Many older distributions come
with libncurses.so.4. Many newer distributions come with libncurses.so.5 (or
newer). Some distributions come with both. If your distribution does NOT have
libncurses.so.4, create a symbolic link to the newer library as follows.</p>
<p>(These instructions assume that your system has ncurses version 5.2 and that
libncurses.so.5.2 resides in /usr/lib. If your system has a different version
of ncurses or if it resides somewhere else (for example, in /lib) then modify
the instructions accordingly)</p>
<blockquote>
<b>cd /usr/lib<br>
ln -s libncurses.so.5.2 libncurses.so.4</b>
</blockquote>
<a name="startingatboot"></a>
<span class="heading2">Starting the Database at Boot Time</span><br>
<p>The package distributions of Interbase and Firebird install a script which
starts the database at boot time and stops it at shutdown time. If you
compiled from source, you'll need to install a script like one of the following
to start/stop the database at boot/shutdown time.</p>
<p>For Firebird 1.5, use the following script:</p>
<blockquote>
<PRE>
<FONT color=#0000ff>#!/bin/sh</FONT>
<B><FONT color=#a62828>case</FONT></B> "$1" <B><FONT color=#a62828>in</FONT></B>
start<B><FONT color=#a62828>)</FONT></B>
su -l firebird <font color="#a52829">"/opt/firebird/bin/fbmgr -start -forever"</font>
<B><FONT color=#a62828>;;</FONT></B>
stop<B><FONT color=#a62828>)</FONT></B>
su -l firebird <font color="#a52829">"/opt/firebird/bin/fbmgr -shut -user sysdba -password changeme"</font>
<B><FONT color=#a62828>;;</FONT></B>
*<B><FONT color=#a62828>)</FONT></B>
<B><FONT color=#a62828>echo</FONT></B><FONT color=#ff00ff> $</FONT><B><FONT color=#a62828>"</FONT></B><FONT color=#ff00ff>Usage: </FONT><FONT color=#a620f7>$0</FONT><FONT color=#ff00ff> {start|stop}</FONT><B><FONT color=#a62828>"</FONT></B>
<B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>1</FONT>
<B><FONT color=#a62828>esac</FONT></B>
<B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>0</FONT>
</PRE>
</blockquote>
<p>For Interbase or Firebird prior to version 1.5, use the following script:</p>
<blockquote>
<PRE>
<FONT color=#0000ff>#!/bin/sh</FONT>
<B><FONT color=#a62828>case</FONT></B> "$1" <B><FONT color=#a62828>in</FONT></B>
start<B><FONT color=#a62828>)</FONT></B>
/opt/interbase/bin/ibmgr -start
<B><FONT color=#a62828>;;</FONT></B>
stop<B><FONT color=#a62828>)</FONT></B>
/opt/interbase/bin/ibmgr -shut -user sysdba -password changeme
<B><FONT color=#a62828>;;</FONT></B>
*<B><FONT color=#a62828>)</FONT></B>
<B><FONT color=#a62828>echo</FONT></B><FONT color=#ff00ff> $</FONT><B><FONT color=#a62828>"</FONT></B><FONT color=#ff00ff>Usage: </FONT><FONT color=#a620f7>$0</FONT><FONT color=#ff00ff> {start|stop}</FONT><B><FONT color=#a62828>"</FONT></B>
<B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>1</FONT>
<B><FONT color=#a62828>esac</FONT></B>
<B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>0</FONT>
</PRE>
</blockquote>
<p>Install this script and run it with the "start" option to start up the
database. Running it with the "stop" option shuts the database down. To
access a database, it must be running.</p>
<p>Note that the /etc/hosts.equiv file must contain an entry for localhost and
possibly localhost.localdomain for the database to start properly and for the
"local" tools (such as <i>ibmgr</i>/<i>fbmgr</i> and <i>gsec</i> to
function.</p>
<a name="creating"></a>
<span class="heading1">Creating a Database</span><br>
<p>After installation, Interbase is ready to use but to do any useful work,
you'll have to create a database.</p>
<p>At this point, you should set up your environment. The Interbase/Firebird
client is called </i>isql</i>. Note that <i>unixODBC</i> and <i>Sybase</i>
have a client called <i>isql</i> as well which could be installed in /usr/bin,
/usr/local/bin, /opt/sybase*/bin or some other path. If you have
<i>unixODBC</i> or <i>Sybase</i> installed, you'll have to decide which client
you want the <i>isql</i> command to run. If you want it to run the
Interbase/Firebird client, follow the instructions below. Otherwise, you'll
have to run the Interbase/Firebird <i>isql</i> client by it's full pathname.</p>
<p>If you are using Interbase or Firebird prior to version 1.5, in the
configuration script for your shell, add <i>/opt/interbase/bin</i> to your
PATH environment variable. If you are using Firebird 1.5, add
<i>/opt/firebird/bin</i> to your PATH environment variable. You can add the
paths as follows.</p>
<p>For Bourne shells:</p>
<blockquote>
<PRE>
<FONT color=#008a8e>PATH</FONT>=<FONT color=#a620f7>$PATH</FONT>:/opt/firebird/bin
<B><FONT color=#a62828>export </FONT></B><FONT color=#008a8e>PATH</FONT>
</PRE>
</blockquote>
<p>or</p>
<blockquote>
<PRE>
<FONT color=#008a8e>PATH</FONT>=<FONT color=#a620f7>$PATH</FONT>:/opt/interbase/bin
<B><FONT color=#a62828>export </FONT></B><FONT color=#008a8e>PATH</FONT>
</PRE>
</blockquote>
<p>For C-shells:</p>
<blockquote>
<PRE>
<B><FONT color=#a62828>setenv</FONT></B> <FONT color=#6959cf>PATH</FONT> <B><FONT color=#288a51>${PATH}</FONT></B>:/opt/firebird/bin
</PRE>
</blockquote>
<p>or</p>
<blockquote>
<PRE>
<B><FONT color=#a62828>setenv</FONT></B> <FONT color=#6959cf>PATH</FONT> <B><FONT color=#288a51>${PATH}</FONT></B>:/opt/interbase/bin
</PRE>
</blockquote>
<p>Now log out and log back in and you can access the database using the
<i>isql</i> client.</p>
<p>Under Firebird 1.5, the installation process creates a security database
called <i>security.fdb</i> containing host and user privileges and an
administrative user named <i>SYSDBA</i> with a randomly generated password.
This password is listed in <i>SYSDBA.password</i>.</p>
<p>Under Interbase or Firebird prior to version 1.5, the installation process
creates a security database named <i>isc4.gdb</i> containing host and user
privileges and an administrative user named <i>SYSDBA</i> with a password of
either <i>changeme</i> or <i>masterkey</i>.</p>
<p>Interbase user names are case insensitive and can be up to 31 characters
long. Interbase passwords are case sensitive and can be up to 32 characters
long, but only the first 8 characters are actually used.</p>
<p>Use the <i>gsec</i> utility to change the <i>SYSDBA</i> password to
<i>newpassword</i> and create a new user named <i>testuser</i> with password
<i>testpassword</i>. <i>gsec</i> must be run as root, from the directory
containing <i>isc4.gdb</i>. A gsec session follows.</p>
<p>Note that the /etc/hosts.equiv file must contain an entry for localhost and
possibly localhost.localdomain for the <i>gsec</i> to function.</p>
<p>For Firebird verison 1.5...</p>
<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/firebird</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l security.fdb</FONT>
-rw-rw-rw- <FONT color=#ff00ff>1</FONT> root root <FONT color=#ff00ff>618496</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>14</FONT>:<FONT color=#ff00ff>29</FONT> security.fdb
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/firebird/bin/gsec</FONT>
GSEC<B><FONT color=#a62828>></FONT></B> modify sysdba <FONT color=#6959cf>-pw</FONT> newpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>></FONT></B> add testuser
GSEC<B><FONT color=#a62828>></FONT></B> modify testuser <FONT color=#6959cf>-pw</FONT> testpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>></FONT></B> quit
</PRE>
</blockquote>
<p>For Interbase or Firebird prior to verison 1.5...</p>
<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/interbase</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l isc4.gdb</FONT>
-rw-rw-rw- <FONT color=#ff00ff>1</FONT> root root <FONT color=#ff00ff>618496</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>14</FONT>:<FONT color=#ff00ff>29</FONT> isc4.gdb
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/interbase/bin/gsec</FONT>
GSEC<B><FONT color=#a62828>></FONT></B> modify sysdba <FONT color=#6959cf>-pw</FONT> newpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>></FONT></B> add testuser
GSEC<B><FONT color=#a62828>></FONT></B> modify testuser <FONT color=#6959cf>-pw</FONT> testpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>></FONT></B> quit
</PRE>
</blockquote>
<p>Now that the <i>SYSDBA</i> password has been changed in the database, you
should update the start/stop script with the new password as well.</p>
<p>Though you can create tables in the <i>isc4.gdb</i> database using the
SYSDBA user, it's not a good idea. You should create a new database using a
regular user. The following sequence of commands creates a database.</p>
<p>For Firebird version 1.5, these commands create a database called
<i>/opt/firebird/testdb.gdb</i> which is owned by <i>testuser</i>.</p>
<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword
Use CONNECT or CREATE DATABASE to specify a database
SQL> <B><FONT color=#a62828>create</FONT></B> database <FONT color=#ff00ff>'/opt/firebird/testdb.gdb'</FONT>;
SQL> quit;
</PRE>
</blockquote>
<p>For Interbase or Firebird prior to version 1.5, these commands create a
database called <i>/opt/interbase/testdb.gdb</i> which is owned by
<i>testuser</i>.</p>
<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword
Use CONNECT or CREATE DATABASE to specify a database
SQL> <B><FONT color=#a62828>create</FONT></B> database <FONT color=#ff00ff>'/opt/interbase/testdb.gdb'</FONT>;
SQL> quit;
</PRE>
</blockquote>
<p>Interbase/Firebird databases are referenced by the pathname of the database
file. If you try to create a database using a file name that already exists or
if you forget to enclose the file name in single quotes, you'll get a cryptic
error indicating that the 'database' token is unknown. So, if you get a
message like that, make sure that you enclosed the file name in single quotes
and make sure that the database file that you're trying to create doesn't
already exist.</p>
<p>Now you can log into the database as <i>testuser</i>.</p>
<p>Use the following command for Firebird 1.5.</p>
<blockquote>
<b>isql -u testuser -p testpassword /opt/firebird/testdb.gdb</b>
</blockquote>
<p>Use the following command for Interbase or Firebird prior to version 1.5.</p>
<blockquote>
<b>isql -u testuser -p testpassword /opt/interbase/testdb.gdb</b>
</blockquote>
<p>The only users that can drop a database are the user that owns the database
and the <i>SYSDBA</i> user. If you want to drop the database, you can do so
using <i>isql</i> as follows for Firebird 1.5...</p>
<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword /opt/firebird/testdb.gdb
Database: /opt/firebird/testdb.gdb, User: testuser
SQL> <B><FONT color=#a62828>drop</FONT></B> database;
SQL> quit;
</PRE>
</blockquote>
<p>Or as follows for Interbase or Firebird prior to version 1.5.</p>
<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword /opt/interbase/testdb.gdb
Database: /opt/interbase/testdb.gdb, User: testuser
SQL> <B><FONT color=#a62828>drop</FONT></B> database;
SQL> quit;
</PRE>
</blockquote>
<p>To delete a user, use the <i>gsec</i> utility as the root user and delete
the appropriate user as follows for Firebird 1.5.</p>
<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/firebird</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l isc4.gdb</FONT>
-rw-rw-rw- <FONT color=#ff00ff>1</FONT> root root <FONT color=#ff00ff>626688</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>20</FONT>:<FONT color=#ff00ff>43</FONT> isc4.gdb
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/firebird/bin/gsec</FONT>
GSEC<B><FONT color=#a62828>></FONT></B> delete testuser
GSEC<B><FONT color=#a62828>></FONT></B> quit
</PRE>
</blockquote>
<p>Or as follows for Interbase or Firebird prior to version 1.5.</p>
<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/interbase</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l isc4.gdb</FONT>
-rw-rw-rw- <FONT color=#ff00ff>1</FONT> root root <FONT color=#ff00ff>626688</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>20</FONT>:<FONT color=#ff00ff>43</FONT> isc4.gdb
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/interbase/bin/gsec</FONT>
GSEC<B><FONT color=#a62828>></FONT></B> delete testuser
GSEC<B><FONT color=#a62828>></FONT></B> quit
</PRE>
</blockquote>
<p>This should be enough to get you started. To set up more complex
configurations, consult the
<a href="http://firebird.sourceforge.net/index.php?op=doc">Interbase
/Firebird documentation</a>.</p>
<a name="accessing"></a>
<span class="heading1">Accessing a Database</span><br>
<p>To access a database called <i>/opt/interbase/testdb.gdb</i> on the local
machine as the <i>testuser</i> user with password <i>testpassword</i>, use the
following command.</p>
<blockquote>
<b>isql -u testuser -p testpassword /opt/interbase/testdb.gdb</b>
</blockquote>
<p>To connect to a database on a remote machine, prepend the database
filename with the remote hostname, followed by a colon. For example, to access
a database called <i>/opt/interbase/testdb.gdb</i> on the remote machine
<i>testhost</i> as the <i>testuser</i> user with password <i>testpassword</i>,
use the following command.</p>
<blockquote>
<b>isql -u testuser -p testpassword testhost:/opt/interbase/testdb.gdb</b>
</blockquote>
<p>Once you're connected to the database, the isql client prompts you to enter
a query. Queries may be split across multiple lines. To run a query,
end it with a semicolon. To exit, type quit;.</p>
<p>A sample <i>isql</i> session follows.</p>
<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpass /opt/interbase/testdb.gdb
Database: /opt/interbase/testdb.gdb, <FONT color=#6959cf>User</FONT>: testuser
SQL> <B><FONT color=#a62828>create</FONT></B> <FONT color=#6959cf>table</FONT> testtable (
CON> col1 <B><FONT color=#288a51>char</FONT></B>(<FONT color=#ff00ff>40</FONT>),
CON> col2 integer
CON> );
SQL> show <FONT color=#6959cf>table</FONT> testtable;
COL1 <B><FONT color=#288a51>CHAR</FONT></B>(<FONT color=#ff00ff>40</FONT>) Nullable
COL2 <B><FONT color=#288a51>INTEGER</FONT></B> Nullable
SQL> <B><FONT color=#a62828>insert</FONT></B> <FONT color=#6959cf>into</FONT> testtable <FONT color=#6959cf>values</FONT> (<FONT color=#ff00ff>'hello'</FONT>,<FONT color=#ff00ff>50</FONT>);
SQL> <B><FONT color=#a62828>insert</FONT></B> <FONT color=#6959cf>into</FONT> testtable <FONT color=#6959cf>values</FONT> (<FONT color=#ff00ff>'hi'</FONT>,<FONT color=#ff00ff>60</FONT>);
SQL> <B><FONT color=#a62828>insert</FONT></B> <FONT color=#6959cf>into</FONT> testtable <FONT color=#6959cf>values</FONT> (<FONT color=#ff00ff>'bye'</FONT>,<FONT color=#ff00ff>70</FONT>);
SQL> <B><FONT color=#a62828>select</FONT></B> * <FONT color=#6959cf>from</FONT> testtable;
COL1 COL2
======================================== ============
hello <FONT color=#ff00ff>50</FONT>
hi <FONT color=#ff00ff>60</FONT>
bye <FONT color=#ff00ff>70</FONT>
SQL> <B><FONT color=#a62828>update</FONT></B> testtable <B><FONT color=#a62828>set</FONT></B> col2=<FONT color=#ff00ff>0</FONT> <FONT color=#6959cf>where</FONT> col1=<FONT color=#ff00ff>'hi'</FONT>;
SQL> <B><FONT color=#a62828>select</FONT></B> * <FONT color=#6959cf>from</FONT> testtable;
COL1 COL2
======================================== ============
hello <FONT color=#ff00ff>50</FONT>
hi <FONT color=#ff00ff>0</FONT>
bye <FONT color=#ff00ff>70</FONT>
SQL> <B><FONT color=#a62828>delete</FONT></B> <FONT color=#6959cf>from</FONT> testtable <FONT color=#6959cf>where</FONT> col2=<FONT color=#ff00ff>50</FONT>;
SQL> <B><FONT color=#a62828>select</FONT></B> * <FONT color=#6959cf>from</FONT> testtable;
COL1 COL2
======================================== ============
hi <FONT color=#ff00ff>0</FONT>
bye <FONT color=#ff00ff>70</FONT>
SQL> <B><FONT color=#a62828>commit</FONT></B>;
SQL> <B><FONT color=#a62828>drop</FONT></B> <FONT color=#6959cf>table</FONT> testtable;
SQL> quit;
</PRE>
</blockquote>
<a name="sqlrelay"></a>
<span class="heading1">Accessing a Database With SQL Relay</span><br>
<p>Accessing Interbase/Firebird from SQL Relay requires an instance entry in
your <i>sqlrelay.conf</i> file for the database that you want
to access. Here is an example <i>sqlrelay.conf</i> which defines an SQL Relay
instance called interbasetest. This instance connects to the
<i>/opt/interbase/testdb</i> database as the user <i>testuser</i> with password
<i>testpassword</i>.</p>
<PRE>
<FONT color=#0000ff><?</FONT><B><FONT color=#288a51>xml version=</FONT></B><FONT color=#ff00ff>"1.0"</FONT><FONT color=#0000ff>?></FONT>
<FONT color=#008a8e><!</FONT><B><FONT color=#a62828>DOCTYPE</FONT></B> instances <B><FONT color=#a62828>SYSTEM</FONT></B> <FONT color=#ff00ff>"sqlrelay.dtd"</FONT><FONT color=#008a8e>></FONT>
<FONT color=#008a8e><instances></FONT>
<FONT color=#008a8e><instance id=</FONT><FONT color=#ff00ff>"interbasetest"</FONT><FONT color=#008a8e> port=</FONT><FONT color=#ff00ff>"9000"</FONT><FONT color=#008a8e> socket=</FONT><FONT color=#ff00ff>"/tmp/interbasetest.socket"</FONT><FONT color=#008a8e> dbase=</FONT><FONT color=#ff00ff>"interbase"</FONT><FONT color=#008a8e> connections=</FONT><FONT color=#ff00ff>"3"</FONT><FONT color=#008a8e> maxconnections=</FONT><FONT color=#ff00ff>"5"</FONT><FONT color=#008a8e> maxqueuelength=</FONT><FONT color=#ff00ff>"0"</FONT><FONT color=#008a8e> growby=</FONT><FONT color=#ff00ff>"1"</FONT><FONT color=#008a8e> ttl=</FONT><FONT color=#ff00ff>"60"</FONT><FONT color=#008a8e> endofsession=</FONT><FONT color=#ff00ff>"commit"</FONT><FONT color=#008a8e> sessiontimeout=</FONT><FONT color=#ff00ff>"600"</FONT><FONT color=#008a8e> runasuser=</FONT><FONT color=#ff00ff>"nobody"</FONT><FONT color=#008a8e> runasgroup=</FONT><FONT color=#ff00ff>"nobody"</FONT><FONT color=#008a8e> cursors=</FONT><FONT color=#ff00ff>"5"</FONT><FONT color=#008a8e> authtier=</FONT><FONT color=#ff00ff>"listener"</FONT><FONT color=#008a8e> handoff=</FONT><FONT color=#ff00ff>"pass"</FONT><FONT color=#008a8e>></FONT>
<FONT color=#008a8e><users></FONT>
<FONT color=#008a8e><user user=</FONT><FONT color=#ff00ff>"interbasetest"</FONT><FONT color=#008a8e> password=</FONT><FONT color=#ff00ff>"interbasetest"</FONT><FONT color=#008a8e>/></FONT>
<FONT color=#008a8e></users></FONT>
<FONT color=#008a8e><connections></FONT>
<FONT color=#008a8e><connection connectionid=</FONT><FONT color=#ff00ff>"interbasetest"</FONT><FONT color=#008a8e> string=</FONT><FONT color=#ff00ff>"user=testuser;password=testpassword;database=/opt/interbase/testdb.gdb;dialect=3"</FONT><FONT color=#008a8e> metric=</FONT><FONT color=#ff00ff>"1"</FONT><FONT color=#008a8e>/></FONT>
<FONT color=#008a8e></connections></FONT>
<FONT color=#008a8e></instance></FONT>
<FONT color=#008a8e></instances></FONT>
</PRE>
<p>Note that in this example, the database parameter of the string attribute in
the connection tag references the local database
<i>/opt/interbase/testdb.gdb</i>.
If you want to access a remote database, prepend the database filename with
the remote hostname followed by a colon. For example:
<i>testhost:/opt/interbase/testdb.gdb</i>.</p>
<p>Now you can start up this instance with the following command.</p>
<blockquote>
<b>sqlr-start -id interbasetest</b>
</blockquote>
<p>To connect to the instance and run queries, use the following command.</p>
<blockquote>
<b>sqlrsh -id interbasetest</b>
</blockquote>
<p>The following command shuts down the SQL Relay instance.</p>
<blockquote>
<b>sqlr-stop interbasetest</b>
</blockquote>
<a name="quirks"></a>
<span class="heading1">Interbase Quirks</span><br>
<p>In most databases, you can create, alter or drop databse objects such as
tables, indices or stored procedures at will. In Interbase/Firebird, you
should create, alter or drop databse objects when you have exclusive access
to the databse.</p>
<p>Basically, you should shut down SQL Relay or any other clients,
use isql to create, alter or drop the objects, then start SQL Relay again.
If you don't do this, you'll get confusing results.</p>
</body>
</html>
|