Does Firebird Database support Schema? If so, how can I create a schema in Firebird DB through ISQL?

4.1k views Asked by At

Does Firebird Database support Schema? If so, how can I create a schema in Firebird DB through ISQL? Please help me to create schemas in Firebird DB. I have tried to retrieve schema using

AbstractDatabaseMetaData.getSchemas()

But it is always retrieving empty resultset. Can anyone please help me in retrieving schemas? At least SYSTEM schema when there is no schema.

2

There are 2 answers

1
Michael Kazarian On

No, schema not supported, but you can create many databases files. Here manual for create database with Firebird tool. Also you can create database with IBExpert or similar tool. Also, you can create sql-cript for automate it:

$ isql -q -i create-db.sql

Also you can run it from java code.

--Contents of create-db.sql
CREATE DATABASE '/my/path/my-db.fdb' page_size 8192 USER 'SYSDBA' PASSWORD 'masterkey';
CREATE EXCEPTION EX_SOME_EXCEPTION 'Some extension message';
CREATE TABLE ROOMS (
 ID integer NOT NULL PRIMARY KEY,
 Number char(10),
 Name char(100),
 Network char(100),
 Memo char(100)
);

CREATE GENERATOR ROOMS_IDGEN;
SET TERM !! ;
CREATE TRIGGER ON_ROOMS_INS FOR ROOMS BEFORE INSERT AS
BEGIN
 IF (NEW.ID IS NULL) THEN NEW.ID=GEN_ID(ROOMS_IDGEN, 1);
END !!
SET TERM ; !!
....
0
Mark Rotteveel On

Firebird currently doesn't have schemas, and therefor Jaybird doesn't return any. This complies with the JDBC specification, which says:

If a given form of metadata is not available, an empty ResultSet will be returned.

Note that Firebird does have a CREATE SCHEMA, but that is simply an alias for CREATE DATABASE.