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 thebatch
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'
/>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Asrc | string | Name of the origin database. | |||
Adst | string | Name of the destination database. | |||
Atables | string | Tables to copy, a name of table or a style pattern capuntes%, all who starts with capuntes. If it is not reported, the system will take all the objects of this type. | |||
Adelete | boolean | false | Indicates if previously the records that could exist in the table of the destination database have to be deleted. | ||
Adrop | boolean | false | Indicates if previously the table of the destination database have to be deleted. | ||
Awhere | string | SQL condition which should be applied to filter the registers to obtain of the origin table. | |||
Askip | integer | Number of initials rows of the origin table which should be discarded in the copy process. | |||
Abatchsize | integer | 1000 | Indicates the number of registers to insert which should be accumulate before being sent in block to the database server. The use of batch increases very considerably the performance of the insertion operations in the destination database. |
Returns | |
---|---|
Type | Description |
Vtable | Returns a vtable with the result. Returns the result for each processed object. |
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.
<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>
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.
<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>