Firebird

From Andreida
Revision as of 11:55, 16 February 2016 by Andreas (talk | contribs) (Created page with "* [http://www.firebirdsql.org Firbird] * [http://stackoverflow.com/questions/8853845/how-to-connect-firebird-db-with-qt Qt+Firebird] == Users == Passwords are case sensitive,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Users

Passwords are case sensitive, user names are not case sensitive.


default user: sysdba / masterkey

change the password for sysdba

gsec -user sysdba -password masterkey
modify SYSDBA -pw <new_password>

add user

gsec -user sysdba -pass <password> -add misterx -pw hispw

Connecting

isql -user sysdba -password <password>
connect <path-to-db-file>;
help;

database

  • exit = commit
  • quit = rollback

create a database

isql -u <user> -p <password>
create database <name>;
exit;
isql -u misterx -p hispw
create database 'test01';
exit;

create a table

isql -u <user> -p <password> <filename>
isql -u misterx -p hispw test01
create table tas_tasks
(
    tas_id integer not null,
    tas_text varchar(50) not null,
    tas_creation timestamp not null
);

make the integer field of your table an autoincrement field

CREATE GENERATOR gen_tas_id;
SET GENERATOR gen_tas_id TO 0;

set term !! ;
CREATE TRIGGER T_tas_auto FOR tas_tasks
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
if (NEW.tas_id is NULL) then NEW.tas_id = GEN_ID(gen_tas_id, 1);
END!!
set term ; !!

to test it, call at least twice:

insert into tas_tasks
(tas_text, tas_creation)
values
('test 1', current_timestamp);

then

select * from tas_tasks;

populate the timestamp at row insertion and/or update

SET TERM ^ ;
CREATE TRIGGER T_tas_create FOR tas_tasks
ACTIVE BEFORE INSERT -- OR UPDATE POSITION 1
AS
BEGIN
new.TAS_CREATION = current_timestamp;
END^
SET TERM ; ^ 

call at least twice:

insert into tas_tasks (tas_text) values ('test 2');

then again

select * from tas_tasks;