21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example:<br />

DDL statements<br />

create global temporary table MyConnGTT (<br />

id int not null primary key,<br />

txt varchar(32),<br />

ts timestamp default current_timestamp<br />

)<br />

on commit preserve rows;<br />

commit;<br />

create global temporary table MyTxGTT (<br />

id int not null primary key,<br />

parent_id int not null references MyConnGTT(id),<br />

txt varchar(32),<br />

ts timestamp default current_timestamp<br />

);<br />

commit;<br />

Tip<br />

In an existing database, it's not always easy to tell a regular table from a GTT, or a transaction-level GTT from<br />

a connection-level GTT. Use this query to find out a table's type:<br />

select t.rdb$type_name<br />

from rdb$relations r<br />

join rdb$types t on r.rdb$relation_type = t.rdb$type<br />

where t.rdb$field_name = 'RDB$RELATION_TYPE'<br />

and r.rdb$relation_name = 'TABLENAME'<br />

Or, for an overview of all your relations:<br />

select r.rdb$relation_name, t.rdb$type_name<br />

from rdb$relations r<br />

join rdb$types t on r.rdb$relation_type = t.rdb$type<br />

where t.rdb$field_name = 'RDB$RELATION_TYPE'<br />

and coalesce (r.rdb$system_flag, 0) = 0<br />

GENERATED ALWAYS AS<br />

Added in: <strong>2.1</strong><br />

Description: Instead of COMPUTED [BY], you may also use the SQL-2003-compliant equivalent GENERATED<br />

ALWAYS AS for computed fields.<br />

Syntax:<br />

Example:<br />

colname [coltype] GENERATED ALWAYS AS (expression)<br />

create table Persons (<br />

id int primary key,<br />

firstname varchar(24) not null,<br />

middlename varchar(24),<br />

38

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!