Firebird

  Home  Databases Programming  Firebird


“Firebird Interview Questions and Answers will teach us now that Firebird is an open source relational database management system that runs on GNU/Linux, Windows, and a variety of Unix platforms. The database forked from Borlands open source edition of InterBase in 2000, so learn Firebird or get preparation for the job of Firebird with the help of this Firebird Interview Questions with Answers guide”



44 Firebird Questions And Answers

41⟩ Why does reading require write privileges on database file?

In order to run the SELECT statmement, it still needs to start a transaction.

If you wish to build a read-only database to place on some read-only media like CD or DVD ROM, you can do it with:

gfix -mode read_only database.fdb

...or within your favorite administration tool. It is also available via ServicesAPI, so you may do it from your application as well. Please note that you can only make this change while preparing the database, because the read-only flag needs to be written in the database file.

When the database becomes read-only, the only thing you can write to is the read_only flag (to reset it back to read-write).

 145 views

42⟩ Is there an example how to configure UdfAccess setting in firebird.conf?

Well, there's one right there in the firebird.conf, but perhaps it isn't obvious enough. Here are the basic settings ('None' to disallow UDFs completely and 'Full' to allow them anywhere) which you probably understood yourself:

UdfAccess = None

UdfAccess = Full

And here is that tricky Restrict setting:

UdfAccess = Restrict C:somedirectory

For multiple directories, use something like this:

UdfAccess = Restrict C:somedirectory;C:someotherdirectory

For Linux users:

UdfAccess = Restrict /some/directory

In the default setting 'Restrict UDF', 'UDF' is a directory relative to root directory of Firebird installation.

 161 views

43⟩ Is there some bulk load or other way to import a lot of data fast?

Currently there is only one way to quickly load a lot of data into database. That is by using external tables. You should read the manual for details, but here's a short explanation. You create a binary or textual file using the external table format and then hook it up in the database using a statement like this:

CREATE TABLE ext1 EXTERNAL 'c:myfile.txt'

(

field1 char(20),

field2 smallint

);

To do quick import into regular table, do something like this:

INSERT INTO realtable1 (field1, field2)

SELECT field1, field2 FROM ext1;

This insert would still check constraints, foreign keys, fire triggers and build indexes. If you can, it is wise to deactivate indexes and triggers while loading and activate them when done.

Make sure you drop the external table when done, in order to release the lock on the file.

The main problem with external tables is handling of NULLs and BLOBs. If you need to deal with those, you're better off using some tool like FBExport. However, please note that external tables are much faster.

 148 views

44⟩ What is the best way to determine whether Firebird server is running?

If you want to do it from an application, a simple try to connect should suffice. Otherwise you have various options:

a) check if firebird server is in the list of running programs (use task manager on Windows, or 'ps ax' command on Linux). Please note that Classic won't be running until there is a connection established.

b) check whether the port 3050 is open on the machine. First, you can check with netstat command, and if it is open, you can test whether it accepts connections by telnet-ing to the port. Just type:

telnet [hostname|IPaddress] 3050

Example:

telnet localhost 3050

If you use Linux, you can also check the open port with 'lsof' command. It outputs a lot, so you might want to 'grep' for 3050 or gds_db strings:

# lsof | grep gds_db

# lsof | grep 3050

c) if all of this fails, perhaps you should check whether the remote server is reachable at all. You can use 'ping' command:

ping [hostname|IPaddress]

Example:

ping 192.168.0.22

Please note that ping can still give you 'host unreachable' message even if host is up. This is because the firewall software can drop the ICMP (ping) packets (it's done to prevent some viruses from spreading, or network scans).

 126 views