Introducing Oracle Backend with Firebase APIs: Build Mobile and Web Apps on Oracle AI Database
本記事ではFusabaseを、United Codes社が提供しているuc-local-apex-devを使って作成したOracle Database FreeとORDS、APEXの環境に構築します。
初期化パラメータcompatibleを23.9.0以上にする
docker exec -it local-26ai bash
% docker exec -it local-26ai bash
bash-4.4$
bash-4.4$ sqlplus / as sysdba
SQL*Plus: Release 23.26.2.0.0 - Production on Wed Jul 22 05:24:33 2026
Version 23.26.2.0.0
Copyright (c) 1982, 2026, Oracle. All rights reserved.
Connected to:
Oracle AI Database 26ai Free Release 23.26.2.0.0 - Develop, Learn, and Run for Free
Version 23.26.2.0.0
SQL>
初期化パラメータcompatibleを確認します。
show parameter compatible
SQL> show parameter compatible
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
compatible string 23.6.0
noncdb_compatible boolean FALSE
SQL>
SQL> ALTER SYSTEM SET COMPATIBLE='23.9.0' SCOPE=SPFILE;
System altered.
SQL>
VARCHAR2の最大サイズを32Kに変更する
alter session set container = freepdb1;
alter pluggable database close immediate;
alter pluggable database open upgrade;
alter system set max_string_size = extended;
@?/rdbms/admin/utl32k.sql
alter pluggable database close;
alter pluggable database open;SQL> alter session set container = freepdb1;
Session altered.
SQL> alter pluggable database close immediate;
Pluggable database altered.
SQL> alter pluggable database open upgrade;
Pluggable database altered.
SQL> alter system set max_string_size = extended;
System altered.
SQL> @?/rdbms/admin/utl32k.sql
Session altered.
Session altered.
DOC>#######################################################################
DOC>#######################################################################
DOC> The following statement will cause an "ORA-01722: invalid number"
DOC> error if the database has not been opened for UPGRADE.
DOC>
DOC> Perform a "SHUTDOWN ABORT" and
DOC> restart using UPGRADE.
DOC>#######################################################################
DOC>#######################################################################
DOC>#
no rows selected
DOC>#######################################################################
DOC>#######################################################################
DOC> The following statement will cause an "ORA-01722: invalid number"
DOC> error if the database does not have compatible >= 12.0.0
DOC>
DOC> Set compatible >= 12.0.0 and retry.
DOC>#######################################################################
DOC>#######################################################################
DOC>#
PL/SQL procedure successfully completed.
Session altered.
502 rows updated.
Commit complete.
System altered.
PL/SQL procedure successfully completed.
Commit complete.
System altered.
Session altered.
Session altered.
Table created.
Table created.
Table created.
Table truncated.
0 rows created.
PL/SQL procedure successfully completed.
STARTTIME
--------------------------------------------------------------------------------
07/22/2026 05:33:22.503006000
PL/SQL procedure successfully completed.
No errors.
PL/SQL procedure successfully completed.
Session altered.
Session altered.
0 rows created.
no rows selected
no rows selected
DOC>#######################################################################
DOC>#######################################################################
DOC> The following statement will cause an "ORA-01722: invalid number"
DOC> error if we encountered an error while modifying a column to
DOC> account for data type length change as a result of enabling or
DOC> disabling 32k types.
DOC>
DOC> Contact Oracle support for assistance.
DOC>#######################################################################
DOC>#######################################################################
DOC>#
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Commit complete.
Package altered.
Session altered.
SQL> alter pluggable database close;
Pluggable database altered.
SQL> alter pluggable database open;
Pluggable database altered.
SQL>
TDEウォレットとマスターキーを構成する
TDEウォレットとマスタキーを構成します。Oracle Database Freeのコンテナ環境を前提として、ウォレットは/opt/oracle/database/FREE/tdeに構成します。
!mkdir -p /opt/oracle/oradata/FREE/tde
!chown -R oracle:oinstall /opt/oracle/oradata/FREE
!chmod 700 /opt/oracle/oradata/FREE/tde
SQL> !mkdir -p /opt/oracle/oradata/FREE/tde
SQL> !chown -R oracle:oinstall /opt/oracle/oradata/FREE
SQL> !chmod 700 /opt/oracle/oradata/FREE/tde
SQL>
ウォレット・ルートを設定します。
ALTER SESSION SET CONTAINER=CDB$ROOT;
ALTER SYSTEM SET wallet_root='/opt/oracle/oradata/FREE' SCOPE=SPFILE;
SQL> ALTER SESSION SET CONTAINER=CDB$ROOT;
Session altered.
SQL> ALTER SYSTEM SET wallet_root='/opt/oracle/oradata/FREE' SCOPE=SPFILE;
System altered.
SQL>
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1603386016 bytes
Fixed Size 5020320 bytes
Variable Size 536870912 bytes
Database Buffers 1056964608 bytes
Redo Buffers 4530176 bytes
Database mounted.
Database opened.
SQL>
ALTER SYSTEM SET tde_configuration='KEYSTORE_CONFIGURATION=FILE' SCOPE=BOTH;
ADMINISTER KEY MANAGEMENT CREATE KEYSTORE IDENTIFIED BY "<strong_keystore_password>";
ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY "<strong_keystore_password>" CONTAINER=ALL;
ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY "<strong_keystore_password>" WITH BACKUP CONTAINER=ALL;
col wrl_type format a10
col wrl_parameter format a40
col status format a8
SELECT WRL_TYPE, WRL_PARAMETER, STATUS FROM V$ENCRYPTION_WALLET;
SQL> ALTER SYSTEM SET tde_configuration='KEYSTORE_CONFIGURATION=FILE' SCOPE=BOTH;
System altered.
SQL> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE IDENTIFIED BY "**********";
keystore altered.
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY "**********" CONTAINER=ALL;
keystore altered.
SQL> ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY "**********" WITH BACKUP CONTAINER=ALL;
keystore altered.
SQL> col wrl_type format a10
SQL> col wrl_parameter format a40
SQL> col status format a8
SQL> SELECT WRL_TYPE, WRL_PARAMETER, STATUS FROM V$ENCRYPTION_WALLET;
WRL_TYPE WRL_PARAMETER STATUS
---------- ---------------------------------------- --------
FILE /opt/oracle/oradata/FREE/tde/ OPEN
FILE OPEN
FILE OPEN
SQL>
ウォレットのステータスがOPENであれば、データベースの構成は完了です。
SQL> exit
Disconnected from Oracle AI Database 26ai Free Release 23.26.2.0.0 - Develop, Learn, and Run for Free
Version 23.26.2.0.0
bash-4.4$ exit
exit
%
Oracle Backend for Firebaseをインストールする
docker exec -it local-26ai-ords bash
% docker exec -it local-26ai-ords bash
[oracle@32c50e30cd10 ords]$
fusabaseのインストーラーを起動します。
/opt/oracle/ords/bin/ords --config /etc/ords/config fusabase install
[oracle@32c50e30cd10 ords]$ cd /etc/ords/config
[oracle@32c50e30cd10 config]$ /opt/oracle/ords/bin/ords --config /etc/ords/config fusabase install
ORDS: Release 26.2 Production on Wed Jul 22 06:05:10 2026
Copyright (c) 2010, 2026, Oracle.
Configuration:
/etc/ords/config
Oracle Backend for Firebase - Interactive Install
Enter a number to select the database pool to install/upgrade FUSABASE.
[1] default jdbc:oracle:thin:@//26ai:1521/FREEPDB1
Choose [1]:
Enter a number to update the value or select option A to Accept and Continue
[1] Enable Feature FUSABASE: Yes
[2] Encryption passphrase for FUSABASE: <generate>
[A] Accept and Continue - Update configuration
[Q] Quit - Do not proceed. No changes
Choose [A]: 2
Sを選択し、パスフレーズとなる文字列を入力します。
Enter your choice for the encryption passphrase for FUSABASE:
[S] Specify your own encryption passphrase
[G] Generate encryption passphrase
[C] Cancel - No Changes
Choose [G]: S
Enter the encryption passphrase for FUSABASE: ***************
Enter a number to update the value or select option A to Accept and Continue
[1] Enable Feature FUSABASE: Yes
[2] Encryption passphrase for FUSABASE: <specified encryption key>
[A] Accept and Continue - Update configuration
[Q] Quit - Do not proceed. No changes
Choose [A]:
Enter a number to update the value or select option A to Accept and Continue
[1] Enable Feature FUSABASE: Yes
[2] Encryption passphrase for FUSABASE: <specified encryption key>
[A] Accept and Continue - Update configuration
[Q] Quit - Do not proceed. No changes
Choose [A]: A
Provide database user name with administrator privileges.
Enter the administrator username: sys
Enter the database password for SYS AS SYSDBA: **********
Connecting to database user: SYS AS SYSDBA url: jdbc:oracle:thin:@//26ai:1521/FREEPDB1
Retrieving information.
The setting named: feature.fusabase was set to: true in configuration: default
The setting named: fusabase.secret.encKey was set to: ****** in configuration: default
Created folder /etc/ords/config/logs
The log file is defaulted to the current working directory located at /etc/ords/config/logs
Installing Oracle Backend for Firebase version 26.2.0-260613 in FREEPDB1
Completed installation for Oracle Backend for Firebase version 26.2.0-260613. Elapsed time: 00:00:02.443
[oracle@32c50e30cd10 config]$
docker restart local-26ai-ords
[oracle@32c50e30cd10 config]$ exit
exit
% docker restart local-26ai-ords
local-26ai-ords
ynakakoshi@Ns-Macbook ~ %
プロジェクト用スキーマを作成する
% sql -name local-26ai-sys
SQLcl: 水 7月 22 15:25:36 2026のリリース26.1 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
接続先:
Oracle AI Database 26ai Free Release 23.26.2.0.0 - Develop, Learn, and Run for Free
Version 23.26.2.0.0
SQL>
GRANT connect, resource TO testuser;
GRANT CREATE SESSION, RESOURCE, DBFS_ROLE TO testuser;
GRANT CREATE TABLE, CREATE VIEW, CREATE PROCEDURE TO testuser;
GRANT CREATE ANY DIRECTORY TO testuser;
SQL> CREATE USER testuser IDENTIFIED BY testpwd QUOTA UNLIMITED ON users;
User TESTUSERは作成されました。
SQL> GRANT connect, resource TO testuser;
Grantが正常に実行されました。
SQL> GRANT CREATE SESSION, RESOURCE, DBFS_ROLE TO testuser;
Grantが正常に実行されました。
SQL> GRANT CREATE TABLE, CREATE VIEW, CREATE PROCEDURE TO testuser;
Grantが正常に実行されました。
SQL> GRANT CREATE ANY DIRECTORY TO testuser;
Grantが正常に実行されました。
SQL>
CREATE USER fusabase_dba IDENTIFIED BY <パスワード> QUOTA UNLIMITED ON USERS;
GRANT baas_dba, dba to fusabase_dba;
SQL> create user fusabase_dba identified by ********** quota unlimited on users;
User FUSABASE_DBAは作成されました。
SQL> GRANT baas_dba, dba to fusabase_dba;
Grantが正常に実行されました。
SQL>
SQL> exit
Oracle AI Database 26ai Free Release 23.26.2.0.0 - Develop, Learn, and Run for Free
Version 23.26.2.0.0から切断されました
ynakakoshi@Ns-Macbook ~ % sql fusabase_dba@localhost/freepdb1
SQLcl: 水 7月 22 15:37:23 2026のリリース26.1 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
パスワード (**********?) **********
Last Successful login time: 水 7月 22 2026 15:37:25 +09:00
接続先:
Oracle AI Database 26ai Free Release 23.26.2.0.0 - Develop, Learn, and Run for Free
Version 23.26.2.0.0
SQL>
BEGIN
OBAAS_ADMIN.OBAAS_ENABLE_SCHEMA(
'TESTUSER',
'BASE_PATH',
'testuser',
FALSE
);
END;
/
COMMIT;
SQL> BEGIN
2 OBAAS_ADMIN.OBAAS_ENABLE_SCHEMA(
3 'TESTUSER',
4 'BASE_PATH',
5 'testuser',
6 FALSE
7 );
8 END;
9 /
10* COMMIT;
PL/SQLプロシージャが正常に完了しました。
コミットが完了しました。
SQL>
Fusabaseに接続する
プロジェクト名はrecipe-workshopとし、Set up using quickstartを選択します。
APEXからFusabaseのデータを参照する
docker exec local-26ai-ords bash -c \
"ords --config /etc/ords/config config --db-pool default set plsql.gateway.mode proxied"
% docker exec local-26ai-ords bash -c \
"ords --config /etc/ords/config config --db-pool default set plsql.gateway.mode proxied"
ORDS: Release 26.2 Production on Wed Jul 22 07:25:08 2026
Copyright (c) 2010, 2026, Oracle.
Configuration:
/etc/ords/config
The setting named: plsql.gateway.mode was set to: proxied in configuration: default
% docker restart local-26ai-ords
local-26ai-ords
%
APEXの管理サービスにサインインし、すでに作成済みのワークスペースAPEXDEVにスキーマTESTUSERを割り当てます。
CREATE OR REPLACE FORCE EDITIONABLE JSON RELATIONAL DUALITY VIEW "EMP$BAAS" AS
SELECT JSON {
'ename' : "ENAME",
'job' : "JOB",
'mgr' : "MGR",
'hiredate' : "HIREDATE",
'sal' : "SAL",
'comm' : "COMM",
'deptno' : "DEPTNO",
'OID' : SYS_MAKE_OID_FROM_PK("EMPNO"),
'_id' : "EMPNO",
'parent_oid' : '_docId'
}
FROM "EMP"
WITH INSERT UPDATE DELETE;




























