Allows to copie the structure and data from one table to another, even between differents databases.

1 connection.schema.copy

This functionality is used to copie data between differents databases. If you try to copy in the same database you can use the function table.copy. If the table do not exist in the database, it is created with the information of the obtained metadata using the JDBC driver. That is why it is necessary to review the physical model in case the table does not exist in destination because sometimes it could be a difference in types of fields or default values that should be corrected previously.

Consideraciones de rendimiento

The use of the batch attribute increases the ratio of number of inserted registers in the destiny table. If the destination database is in transactional mode, this will affect negatively in the performance of the insertion operations in the destination table.

<connection.schema.copy    src='src'    dst='dst'    tables='tables'    delete='delete'    drop='drop'    where='where'    skip='skip'    batchsize='batchsize'/>
Example

The following example copy all the tables of the 'db_ori' database in the 'db_dst' database. If the tables does not exist in the destination, they will created. The existing registers in the destination tables will not be affected.

Copy
<xsql-script>
<body>
<set name='time_start'><system.currentTimeMillis /></set>
<connection.schema.copy src='db_ori' dst='db_dst' />
<set name='time_end'><system.currentTimeMillis /></set>
<println>The database copy process takes: <sub><time_end/><time_start/></sub> ms.</println>
</body>
</xsql-script>
Example

Copies the registers of the table 'capuntes' which accomplish the condition 'apteid > 100' of the 'db_ori' database to the 'db_dst' database. The existing registers in the destination tables will not be afected.

Copy
<xsql-script>
<body>
<set name='time_start'><system.currentTimeMillis /></set>
<connection.schema.copy src='db_ori' dst='db_dst' tables='capuntes' where='apteid > 100' />
<set name='time_end'><system.currentTimeMillis /></set>
<println>The database copy process takes: <sub><time_end/><time_start/></sub> ms.</println>
</body>
</xsql-script>