Working with Firebird Databases
Using a Database

Database User:

Path to Data:

IBExpert: Creating Database for use by Firebird (Embedded)
IBExpert: Creating Tables in an existing Database
/******************************************************************************/
/****              Generated by IBExpert 6/13/2005 3:47:55 PM              ****/
/******************************************************************************/
 
SET NAMES NONE;
 
 
 
/******************************************************************************/
/****                                Tables                                ****/
/******************************************************************************/
 
 
CREATE GENERATOR gen_reportid;
 
CREATE TABLE report (
    reportid    INTEGER NOT NULL,
    shortname   VARCHAR(20) NOT NULL,
    longname    VARCHAR(200) NOT NULL,
    dir         VARCHAR(200),
    createdate  DATE NOT NULL,
    intro       BLOB SUB_TYPE 0 SEGMENT SIZE 80,
    body        BLOB SUB_TYPE 0 SEGMENT SIZE 80
);
 
 
 
 
/******************************************************************************/
/****                             Primary Keys                             ****/
/******************************************************************************/
 
ALTER TABLE report ADD CONSTRAINT pk_reportid PRIMARY KEY (reportid);
 
 
/******************************************************************************/
/****                               Indices                                ****/
/******************************************************************************/
 
CREATE INDEX namebydatex ON report (shortname, createdate);
CREATE INDEX shortnamex ON report (shortname);
 
 
/******************************************************************************/
/****                               Triggers                               ****/
/******************************************************************************/
 
 
SET TERM ^ ;
 
 
/******************************************************************************/
/****                         Triggers for tables                          ****/
/******************************************************************************/
 
 
 
/* Trigger: SET_REPORTID */
CREATE TRIGGER set_reportid FOR report
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.reportid IS NULL) THEN
    NEW.reportid = GEN_ID(gen_reportid,1);
END
^
 
 
SET TERM ; ^
 
 
 
/******************************************************************************/
/****                              Privileges                              ****/
/******************************************************************************/
/******************************************************************************/
/****              Generated by IBExpert 6/13/2005 4:03:11 PM              ****/
/******************************************************************************/
 
SET NAMES NONE;
 
 
 
/******************************************************************************/
/****                                Tables                                ****/
/******************************************************************************/
 
 
 
CREATE TABLE photo (
    reportid    INTEGER NOT NULL,
    createdate  DATE NOT NULL,
    filename    VARCHAR(50) NOT NULL,
    dir         VARCHAR(200),
    category    VARCHAR(200),
    caption     VARCHAR(300)
);
 
 
 
 
/******************************************************************************/
/****                             Primary Keys                             ****/
/******************************************************************************/
 
ALTER TABLE photo ADD CONSTRAINT pk_photo PRIMARY KEY (reportid, createdate, filename);
 
 
/******************************************************************************/
/****                             Foreign Keys                             ****/
/******************************************************************************/
 
ALTER TABLE photo ADD CONSTRAINT fk_photo_report FOREIGN KEY (reportid) 
    REFERENCES report (reportid) ON DELETE CASCADE ON UPDATE CASCADE;
 
 
/******************************************************************************/
/****                              Privileges                              ****/
/******************************************************************************/
SET TERM ^ ;
 
CREATE PROCEDURE P_GET_REPORTID 
RETURNS (
    REPORTID INTEGER)
AS
BEGIN
   REPORTID = GEN_ID(gen_reportid, 1);
END
^
 
SET TERM ; ^
 
GRANT EXECUTE ON PROCEDURE P_GET_REPORTID TO SYSDBA;
Controlling InterBase Service from Command Line
Value Meaning
0x00 Boot
0x01 System
0x02 Autoload
0x03 On demand (manual)
0x04 Disabled (filesystem drivers will load anyway)
C:\> sc localhost config InterBaseServer start=demand
My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InterBaseServer\Start = 0x00000003
Frequently Asked Questions

How to check whether a table exists or not?

SELECT RDB$RELATION_NAME FROM RDB$RELATIONS /* all tables will be shown    */
   WHERE RDB$RELATION_NAME = 'your_TABLE'   /* particular table is checked */