On this page

LINK TABLE

Core command LINKT

Links a table of another connection into the current H2 database, without copying its rows.

Syntax

LINK TABLE <connection> <table>

Arguments

ArgumentRequiredValuesDefault
<connection>YesThe active connection the table is read from, of any typeNone
<table>YesThe table of that connection; the linked table gets the same nameNone

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.

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.

Last modified in release development.

Found something wrong or unclear on this page? , with the page address.