Table of Contents
Valentina Dump Features
Valentina can DUMP the whole database or one of its table into XML or SQL dump and later LOAD the dump file. Using this feature you can solve the next tasks:
- dump the whole database and load it to create fresh database.
- dump one table and later load it into other database.
XML Correction of RecIDs
Valentina engine takes care about auto-correction of ObjectPtr values because after LOAD into the new database RecID values of records will be changed most probably (if in original database exists deleted records).
To resolve this problem Valentina dumps ObjectPtr fields using {RecID + ObjectPtr} values as pair to get usually relational picture of PK + FK. During LOAD Valentina creates additional tmp field to load ObjectPtr as ULONG and establish Foreign Key link, then convert FK to ObjectPtr link and deletes tmp fields.
Similar correction happens for BinaryLinks, which also keep RecID values of linked records.
SQL Correction of RecIDs
For SQL dumps we use another technique to get SQL dump which already have corrected values of ObjectPtr fields and BinaryLinks.
[NEW v.4.0] SQL-dump - ordered DDL commands
There is a new global system property DumpSortOrder. It could be set to kSorted or kSchemaDefined.
set property DumpSortOrder to 'kSorted'; set property DumpSortOrder to 'kSchemaDefined';
Default value is kSchemaDefined. If kSorted is set, all DDL commands such as “CREATE TABLE” “ALTER TABLE” “CREATE PROCEDURE” and so on will be placed into the dump in alphabetical order. In case of kSchemaDefined all such commands go in “creation” order.
Example: Assume there is some database consists of two tables.
CREATE TABLE t2 ( f2 long, f1 long ); CREATE TABLE t1 ( f4 long, f3 long );
Do the SQL dump for it. In case of DumpSortOrder is set to kSchemaDefined we get something like:
CREATE TABLE t2 ( f2 long, f1 long ); CREATE TABLE t1 ( f4 long, f3 long );
Now, set DumpSortOrder to kSorted and get this one:
CREATE TABLE t1 ( f3 long, f4 long ); CREATE TABLE t2 ( f1 long, f2 long );
So if you want to get SQL-dumps with ordered DDL you should set DumpSortOrder property to kSorted before dumping.
It could be helpful for doing the dump DIFF on two different databases.
API Methods
To perform XML or SQL dump you can use VDatabase.Dump() or VTable.Dump() methods: