顯示具有 Firebird 標籤的文章。 顯示所有文章
顯示具有 Firebird 標籤的文章。 顯示所有文章

2017/08/09

論 Firebird Embedded 最小部署與 SQLite 的比較 (CHT)


最近看嵌入式資料庫,找到 SQLite 和 Firebird embedded (emb) 的比較,SQLite 相當輕巧,搭配優良的開發工具,在部署時甚至不需要打包 sqlite3.dll 引擎。

真不甘心,Firebird embedded 也有最小配置啊!

就來整理一下,Firebird embedded 到底可以有多小吧!

最小配置:
  • fbembed.dll (視連接 Driver 可能需要改名為 fbclient.dll 或 gds32.dll)
  • icudt30.dll
  • icuin30.dll
  • icuuc30.dll

使用【最小配置】就可以連線 Firebird emb 資料庫。

但是會有副作用──在【每次】連線時會產生Log,並紀錄於「firebird.log」檔案,內容大致如下:

2015/05/05

Firebird 版本選擇:Classic, SuperClassic, SuperServer

Firebird 官方說明文件:Classic, SuperClassic or Superserver?

Classic:

連線方式採 1 程序(Process)對應 1 連線,單一程序崩潰時並不影響其它連線。

SuperClassic、SuperServer:


  • 採 1 程序對應所有連線,該程序如果崩潰即所有連線都會異常。
  • 承上,崩潰後該程序會自動重啟。

資源分配上:

SuperServer > SuperClassic > Classic。
(※SuperServer 還多了一個作弊緩衝區)

只有 Classic 和 SuperClassic 能同時連線。

SuperServer 在 Windows 下預設只採用第一個認到的核心。必須到 firebird.conf 設定 CpuAffinityMask。

本機連線:

只有 Classic 和 SuperClassic 提供,有安全性的問題,但搭配單機版應用程式下非常實用。

三款都有各自的特色。
如果還是不知道要用哪個,就下載 SuperClassic 吧。


2015/05/06補充:
謝謝Delphi.KTOP的leveon大提供額外的資訊,還有附圖解說,十分詳盡。
傳送門:Firebird – SuperServer, ClassicServer or SuperClassic?

另外,據說Firebird 3.0之後這三者會合成一個,不知道正式版發行後是不是真的會成真,期待早日釋出。

2015/04/07

FireBird測試使用的資料庫

每每要測試資料庫時都很煩腦沒有測試使用的資料庫。

常見的北風資料庫很不錯,但就是要安裝 SQL Server 這點就比較麻煩。

剛剛在這裡找到Borland Interbase 6.0搭載的範例資料庫,搭配Firebird emb上很好測試。

在這邊記錄一下連結:

mirrors for employee.gdb

2014/06/27

FireBird Recursive (遞迴) 的支援

今天在查詢 SQL SERVER 對遞迴的支援時,查到這個網頁

一試果然提升效率 600%

那 FireBird 能否支援呢?
請參考 FireBird Select -- Recursive CTEs 一節

2014/06/16

Session function in FireBird

我在 Session funtion programming in PostgreSQL's PL/pgSQL 這篇文章中有提到:
PostgreSQL 對 Session function 的支援程度。

這次換上 FireBird 又會擦出什麼火花呢?

在 FireBird 裡,所使用的是 DSQL (Dynamic SQL) ,在 FireBird 2.0 新增,2.1 和 2.5 都有部分調整。

實際操作的感覺是:
即時性的 PSQL 在 DSQL 下實現 (“on-the-fly” PSQL within a DSQL context.)

語法是:EXECUTE BLOCK

  • EXECUTE BLOCK 做單一值的回傳
語法如下:
execute block
returns (mm Integer)
as
begin
  mm = 100;
  suspend;  --要加這句話做回傳輸出
end

如此,我們會得到


  • 帶有參數的處理語法如下:
EXECUTE BLOCK(arge1 Integer = ? arge1, arge2 Integer = ? arge2)
   RETURNS (SimpleSum Integer)
AS
BEGIN
  SimpleSum = arge1 + arge2;
  suspend;
END

執行畫面:

執行結果:



  • 要取得資料集合的方式如下:
EXECUTE BLOCK
   RETURNS (arge varchar(100))
AS
BEGIN
  FOR SELECT cast(KDT as varchar(100)) FROM M_TSE WHERE KDT >= '2014/06/16' into :arge
  DO
  suspend;
END

會得到



總結:
雖然沒有像 SQL Server 那樣的方便,但也算得上比 PostgreSQL 好設計,在 Run-Time 時期的作業有更多選擇了! :D


See also:
DSQL, ESQL, PSQL, ISQL 名詞解釋
FireBird Document: EXECUTE BLOCK

2009/02/11

Firebird 不支援 TRUNCATE TABLE 指令

來源:http://www.firebirdnews.org/?p=2075=1
以下節錄:

Few notes about level of support of TRUNCATE statement in Firebird :

a) as we have no IDENTITY we can ignore and all related rules
(Syntax rule 4, Genereal rule 8)

Firebird中沒有IDENTITY,所以不用找了 (笑)

b) Syntax rule 2 means TRUNCATE TABLE is not applicable to VIEW’s

TRUNCATE TABLE 不能用在VIEW's

c) Syntax rule 3 means truncated table must not participate in FOREIGN KEY constraints as
master table.
ORACLE relaxed this rule and allow self-referenced constraints. I think we can follow it.

d) as we have no subrows we can ignore General rule 5

e) it will be good to implement TRUNCATE privilege to satisfy Access rules but for the first time
we can allow to TRUNCATE table only for SYSDBA and OWNER.

Firebird資料庫有優異的TRUNCATE存取規則,但初步我們只開放「SYSDBA」和「OWNER」有TRUNCATE權限。

ORACLE used DROP TABLE privilege to control usage of TRUNCATE TABLE statement, while MSSQL used ALTER TABLE privilege.

From the implementation point of view i have some concerns. All the code which released
table’s and indexes pages without removing relation itself is already present. It may require
some small changes but i see no problem with it.

The main concern is about rollback’s (or undo). If we will perform TRUNCATE TABLE as usual
DML statement, i.e. not defer it to transaction commit time, then we must implement support
for undo-log. Also we must decide if we will preserve truncated contents for older still active
concurrent transactions. And specify when this content will be erased finally.

Another approach is to require exclusive lock on table when TRUNCATE is issued (to prevent
any concurrent access to table’s data) and to defer TRUNCATE execution to the commit time. It
allows us to not preserve table contents for the indefinite time and to avoid complex manipulations with undo-log.

Note, ORACLE can’t rollback TRUNCATE statement. MSSQL 2005 don’t log truncation of big
objects and defer physical deallocation until commit time. All pages remains locked until commit
so no concurrent access to truncated data is allowed, AFAIU. IIRC, MSSQL before 2005 also can’t
rollback TRUNCATE statement.


看來是為了安全性的考量…

(20090429修改--始)

Firebird說明仍能有條件地使用 TRUNCATE 指令

但我怎麼樣都試不出來……

(20090429修改--完)

要刪資料?只能慢慢刪或重建table了…Orz