Subject | Feature request - Linked tables (data federation) |
---|---|
Author | dvenus999 |
Post date | 2010-11-11T15:29:25Z |
Hi!
While version 2.5 brings the ability to query other Firebird databases thru the EXECUTE ON EXTERNAL PSQL statement I would like to suggest that the architecture and development teams look at the way that the H2 database handles linked tables. It specifies the JDBC driver in the creation of the linked table. This is similar to Oracle's database links and MS SQL Servers linked servers. Perhaps this could be done as part of the "FB/Java" plugin that was being developed for Version 3.0?
The ability to extend the reach of Firebird to other data sources would draw more people to Firebird as data could be left where it is and not need to be extracted and copied into Firebird. Any database that has a JDBC driver would be available to be used within Firebird.
Below is the documentation from the H2 reference manual on the 'create linked table' command.
CREATE LINKED TABLE
CREATE [ [ GLOBAL | LOCAL ] TEMPORARY ] LINKED TABLE [ IF NOT EXISTS ]
name ( driverString, urlString, userString, passwordString,
[ originalSchemaString, ] originalTableString ) [ EMIT UPDATES | READONLY ]
Creates a table link to an external table. The driver name may be empty if the driver is already loaded. If the schema name is
not set, only one table with that name may exist in the target database.
Usually, for update statements, the old rows are deleted first and then the new rows are inserted. It is possible to emit update
statements (except on rollback), however in this case multi-row unique key updates may not always work. Linked tables to the
same database share one connection.
If a query is used instead of the original table name, the table is read only. Queries must be enclosed in parenthesis: (SELECT *
FROM ORDERS).
To use JNDI to get the connection, the driver class must be a javax.naming.Context (for example javax.naming.InitialContext),
and the URL must be the resource name (for example java:comp/env/jdbc/Test).
Admin rights are required to execute this command. This command commits an open transaction.
Example:
CREATE LINKED TABLE LINK('org.h2.Driver', 'jdbc:h2:test2', 'sa', 'sa', 'TEST');
CREATE LINKED TABLE LINK('', 'jdbc:h2:test2', 'sa', 'sa',
'(SELECT * FROM TEST WHERE ID>0)');
CREATE LINKED TABLE LINK('javax.naming.InitialContext',
'java:comp/env/jdbc/Test', NULL, NULL, '(SELECT * FROM TEST WHERE ID>0)');
Thanks for your consideration of this request!
Dave Venus
While version 2.5 brings the ability to query other Firebird databases thru the EXECUTE ON EXTERNAL PSQL statement I would like to suggest that the architecture and development teams look at the way that the H2 database handles linked tables. It specifies the JDBC driver in the creation of the linked table. This is similar to Oracle's database links and MS SQL Servers linked servers. Perhaps this could be done as part of the "FB/Java" plugin that was being developed for Version 3.0?
The ability to extend the reach of Firebird to other data sources would draw more people to Firebird as data could be left where it is and not need to be extracted and copied into Firebird. Any database that has a JDBC driver would be available to be used within Firebird.
Below is the documentation from the H2 reference manual on the 'create linked table' command.
CREATE LINKED TABLE
CREATE [ [ GLOBAL | LOCAL ] TEMPORARY ] LINKED TABLE [ IF NOT EXISTS ]
name ( driverString, urlString, userString, passwordString,
[ originalSchemaString, ] originalTableString ) [ EMIT UPDATES | READONLY ]
Creates a table link to an external table. The driver name may be empty if the driver is already loaded. If the schema name is
not set, only one table with that name may exist in the target database.
Usually, for update statements, the old rows are deleted first and then the new rows are inserted. It is possible to emit update
statements (except on rollback), however in this case multi-row unique key updates may not always work. Linked tables to the
same database share one connection.
If a query is used instead of the original table name, the table is read only. Queries must be enclosed in parenthesis: (SELECT *
FROM ORDERS).
To use JNDI to get the connection, the driver class must be a javax.naming.Context (for example javax.naming.InitialContext),
and the URL must be the resource name (for example java:comp/env/jdbc/Test).
Admin rights are required to execute this command. This command commits an open transaction.
Example:
CREATE LINKED TABLE LINK('org.h2.Driver', 'jdbc:h2:test2', 'sa', 'sa', 'TEST');
CREATE LINKED TABLE LINK('', 'jdbc:h2:test2', 'sa', 'sa',
'(SELECT * FROM TEST WHERE ID>0)');
CREATE LINKED TABLE LINK('javax.naming.InitialContext',
'java:comp/env/jdbc/Test', NULL, NULL, '(SELECT * FROM TEST WHERE ID>0)');
Thanks for your consideration of this request!
Dave Venus