On this page
LINK TABLE
Links a table of another connection into the current H2 database, without copying its rows.
Syntax
LINK TABLE <connection> <table>
Arguments
| Argument | Required | Values | Default |
|---|---|---|---|
<connection> | Yes | The active connection the table is read from, of any type | None |
<table> | Yes | The table of that connection; the linked table gets the same name | None |
Examples
LINK TABLE mydb01 CUSTOMERS;
LINKT mydb01 CUSTOMERS;
Details
Requirements
The command runs H2's CREATE LINKED TABLE on the current connection, so the current connection must be an H2 database; on any other database it is refused before anything is sent. The other connection is the source the linked table reads. It can be of any type whose JDBC driver BroadSQL has (H2, HSQLDB, PostgreSQL, a driver added to the drivers folder...), since H2 reaches it through that driver. It must be an active connection that can be reached: it is tested before linking.
A live link, not a copy
The rows are not copied: every query on the linked table reads them from the other database. The table name is both the table read in the other database and the name of the linked table in the current database; it cannot be linked under another name. To copy the rows instead, use DUMP ... AS H2.
Password
H2 keeps the other connection's user and password in the linked table's definition, since it needs them to reach the data. BroadSQL never shows that password in its own messages.
The configuration database
BroadSQL's configuration database (the CDF) is never linked: $CDF, or any connection that opens its file or a copy of it, is refused, since the link would store the master password in another database. In CDF maintenance mode, LINK TABLE is refused, since it would create a table in the CDF.
Related
- DUMP, to copy the rows into H2 instead
- Local H2 copies
Last modified in release development.
Found something wrong or unclear on this page? Tell us, with the page address.