|Firebird Interview Questions & Answers - Learning Mode|
DATABASE INTERVIEW QUESTIONS
FIREBIRD INTERVIEW QUESTIONS QUESTIONS & ANSWERS - LEARNING MODE
Firebird Interview Questions & Answers - Learning Mode
Firebird is a relational database offering many ANSI SQL standard features that runs on Linux, Windows, and a variety of Unix platforms. Firebird offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers. Firebird is an open source SQL relational database management system that runs on Linux, Microsoft Windows, Mac OS X and a variety of Unix. The database forked from Borland's open source edition of InterBase in 2000, but since Firebird 1.5 the code has been largely rewritten. Initial release: 2000.
|Try Firebird Interview Questions & Answers - Exam Mode|
|Firebird Interview Questions & Answers - Learning Mode|
|Try Firebird Interview Questions & Answers - Exam Mode|
Question: How to deactivate triggers?
Answer: You can use these SQL commands:
ALTER TRIGGER trigger_name INACTIVE;
ALTER TRIGGER trigger_name ACTIVE;
Most tools have options to activate and deactivate all triggers for a table. For example, in FlameRobin, open the properties screen for a table, click on Triggers at top and then Activate or Deactivate All Triggers options at the bottom of the page. Source: CoolInterview.com
Question: How to select a random record from a table?
Answer: There is no such feature in Firebird, but you can use some tricks. The following example requires that you have a unique integer column (primary key is usually used):
FROM table t1
ORDER BY (t1.int_col + seed)*4294967291-((t1.int_col + seed)*4294967291/49157)*49157;
If you just need one random record, limit the result set using FIRST or ROWS clause. This query will give consistent records for the same seed. If you wish to be complet Source: CoolInterview.com
Question: How to stop SuperServer service on Linux using only Firebird tools?
Answer: The server is started and stopped by 'fbmgr' executable from 'bin' directory of your Firebird installation. It is called 'ibmgr' in Firebird 1.0. To start the server type:
To start the server with Guardian (Guardian watches the server and restarts it if it crashes) type:
/opt/firebird/bin/fbmgr -start -forever
To stop a running server, type:
/opt/firebird/bin/fbmgr -shut -user SYSDBA -pass *****
To f Source: CoolInterview.com
Question: How to configure events with firewall?
Answer: If firewall is on client, you don't have to do anything special. If firewall is on the server, you need to set RemoteAuxPort setting in Firebird.conf file and forward traffic from firewall to that port. Source: CoolInterview.com
Question: How to tell Firebird to only accept conections from XYZ host or network?
Answer: This isn't really a thing you should be configuring in Firebird. There is a RemoteBindAddress setting in firebird.conf which configures on which interfaces/addresses the Firebird listens but that's all. You should really use your system's firewall to set this up.
Beside firewall, if you use Classic on Linux, you can use xinetd or inetd access control files /etc/hosts.allow and /etc/hosts.deny. With xinetd you can also edit the xinetd configuration file for Firebird service, wh Source: CoolInterview.com
Question: How to use events with ZeBeDee, SSH or stunnel?
Answer: You have to use SuperServer, set up RemoteAuxPort setting in firebird.conf and create two tunnels (one for data, other for events). Source: CoolInterview.com
Question: How to do replication of Firebird databases?
Answer: Firebird does not offer replication out-of-the-box, you need to use some 3rd party tools. Those external tools add specific triggers that log all the changes in database and replicate to other databases.
Question: How to migrate Paradox, dBase or FoxPro database to Firebird?
Answer: The easiest way is to download the freeware IBDataPump by CleverComponents. It will extract the metadata from Paradox/dBase/FoxPro database, create all the tables in a Firebird database and then copy all the data. You'll probably have a ready-to-go Firebird database in less than one hour. Source: CoolInterview.com
Question: How to write UDF s in Delphi?
Answer: It's quite simple, the only thing you need to remember is that you must always use ib_util_malloc() to allocate memory if your UDF returns string result. The UDF must be declared as FREE_IT, so that Firebird releases the memory after it reads the string.
To use ib_util_malloc(), you need to import it from ib_util.dll into your program - and make sure you use it instead of regular memory alocating functions. Here's a simple example of Delphi UDF:
function ib_util_malloc( Source: CoolInterview.com
Question: How to activate all indexes in Firebird?
Answer: If you run Firebird 1.x which doesn't have EXECUTE BLOCK, you can run the following query:
select 'ALTER INDEX '||rdb$index_name ||' ACTIVE;'
where rdb$system_flag is not null and rdb$system_flag = 0 Source: CoolInterview.com
Question: Is there a way to detect whether fbclient.dll or fbembed.dll is loaded?
Answer: There are some ways to detect it:
- check the size of DLL file
- if you are using different versions of Firebird (for example 1.5.4 and 2.0.1, you can query the server version via Services API)
You should understand that fbembed can be used as a regular Firebird client. Checking whether embedded or fbclient is loaded for licensing or similar needs is really not useful. You could use the connection string as guide, but super server can establish direct local connections witho Source: CoolInterview.com
Question: How to repair a corrupt Firebird database?
Answer: Here's a short step-by-step walkthrough:
* disconnect users and disable incoming connections to the database
* make a copy of database file (or two copies) and work on that
* use GFIX with -v option to validate the database file
* use GFIX with -v and -f to do full validation
If problem is not too serious, you can try to backup the broken db and restore under a new name:
* use GFIX -mend to prepare corrupt database for backup
* use GBAK -b -g to backup the da Source: CoolInterview.com
Question: How to detect applications and users that hold transactions open too long?
Answer: To do this, you need Firebird 2.1 or a higher version. First, run gstat tool (from your Firebird installation's bin directory), and you'll get an output like this:
gstat -h faqs.gdb
Database header page information:
Page size 4096
ODS version 11.1
Oldest transaction 812
Oldest active 813
Oldest snapshot 813
Next transaction 814
Now, connect to that database and query the MON$TRANS Source: CoolInterview.com
Question: How to lock records in a table?
Answer: While there shouldn't be many reasons to do this in MGA database system like Firebird, there are ways to do it.
One is to use a dummy update for all the records you wish to lock. Many developers do this by accident and get the deadlocks. Example that locks employee 8:
-- start transaction
update employee set emp_no = emp_no where emp_no = 8;
update employee set ... where emp_no = 8;
-- end transaction
A more elegant way is to use the SELECT ... WITH L Source: CoolInterview.com
Question: How to detect the server version?
Answer: You can get this via Firebird Service API. It does not work for Firebird Classic 1.0, so if you don't get an answer you'll know it's Firebird Classic 1.0 or InterBase Classic 6.0. Otherwise it returns a string like this:
LI-V126.96.36.19948 Firebird 2.0
LI-V188.8.131.5270 Firebird 1.5
The use of API depends on programming language and connectivity library you use. Some might even not provide it. Those that do, call the isc_info_svc_server_version API.
Question: What is command for supporting foreign key in Firebird?
Answer: Lets do it by example:
create table Master_A( mst_1 integer not null primary key,
create table slave_of_a(slv_1 integer not null, primary key,
alter table slave_of_a add constraint FK_2_MST foreign key (mst_1) references Master_A(mst_1);
Is the same command that sql92 supports.
alter table table_name add constraint constraint_name foreign key (field1,field2,...) references
master_table(field1,field2...,); Source: CoolInterview.com
Question: Is there an example how to configure ExternalFileAccess setting in firebird.conf?
Answer: Firebird's config file (firebird.conf) does have descriptions inside that explain everything, but sometimes they are confusing and hard to understand what should you do exactly if you don't have examples. One of such settings is ExternalFileAccess. Some people are even tempted to put Full as it is much easier than trying to guess what's the correct format. Here are the basic settings ('None' to disallow external tables and 'Full' to allow them anywhere) which you prob Source: CoolInterview.com
Question: Why does reading require write privileges on database file?
Answer: 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 wr Source: CoolInterview.com
Question: How to specify transaction or query timeout?
Answer: In order to keep the server low reasonable, you might want to limit the time a single query can consume. Firebird does not support this directly yet (there are plans for Firebird 3.0).
However, you could periodically query the monitoring tables (Firebird 2.1 and above) to detect and cancel long running queries. You can do:
SELECT * FROM MON$STATEMENTS;
Look for those having MON$STATE set to 1.
Please note that your database needs to be at least ODS 11.1, i.e. created Source: CoolInterview.com
Question: How to load a file into database column?
Answer: While some other database systems might have an SQL function for this, with Firebird you need an application. Datatype that holds binary files is called BLOB, and you should use sub_type zero, as sub_type one is for text-only data. Let's create a table to hold the file. We'll have a filename column and a blob column containing the file itself:
CREATE TABLE t1
file_data BLOB SUB_TYPE 0
The blobs are loaded via parametrized query:
< Source: CoolInterview.com
India News Network
Latest 20 Questions
Payment of time- barred debt is:
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal