Changes between Version 15 and Version 16 of DatabaseBasedAnalysis/table2sql
- Timestamp:
- 08/15/18 09:32:56 (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DatabaseBasedAnalysis/table2sql
v15 v16 129 129 Note that the combination of these columns must be unique. 130 130 131 == Ignore duplicate entries == 131 == Duplicate Entries == 132 133 === Ignore === 132 134 133 135 Usually, the `INSERT` query would fail if another row with the same primary key exists already. This can be avoided adding the `IGNORE` keyword to the `INSERT` query by `--ignore-errors`, which essentially ignores all errors and turns them into warnings which are printed after the query succeede. 134 136 135 == Update duplicate entries==137 === Update === 136 138 137 139 Another option is to update duplicate entries. This can be done using the `ON DUPLICATE KEY UPDATE` directive. Giving `-duplicate`, you can specify what should be updated in case of a duplicate key. To keep the row untouched, you can just update the primary key with the identical primary key, e.g. … … 143 145 The `--duplicate` resource can be specified more than once to add more expressions to the assignment_list. For more details, see the MySQL manual. 144 146 145 == Insert constant values == 147 == Constant value columns == 148 === Add a constant value === 146 149 147 150 Sometimes it might be necessary to insert a constant value for each file which is processed (for example a file ID which is not part of the stored data). This can be achieved by the `--fixed.COLUMN=VALUE` directive where '''COLUMN''' the column name and '''VALUE''' is the value filled into the column. As default, the column is create as '''INT UNSIGNED''' but this can be overwritten as usual with the `--sql-type` directive. … … 153 156 would be match the _1234_ in the filename ''file_12345_name.ext''. It would be replaced by the first sub-sequence (%1) which is '12345'. ($0 is the whole match ''_12345_''). 154 157 155 == Conditional execution==158 === Conditional execution === 156 159 157 160 Based on the constant values, conditional execution can be enable with `--conditional`. After dropping/creating the table, it is checked by a `SELECT` query whether at least one entry which fits the constant value columns exists. If at least one exists, further execution is stopped. 158 161 159 == Pre-deleting entries==162 === Pre-deleting entries === 160 163 161 164 Usually the previously defined constant values are helpful to create an index which relates unambiguously the inserted data to the file. It might be useful to delete all data which belongs to this particular file before new data is entered. This can be achieved with the `--delete` directive. It deletes all data from the table before inserting new data which fulfills the condition defined by the `--const` directives. 162 165 163 == Corresponding Index==166 === Corresponding Index === 164 167 165 168 To do the pre-deleting efficiently, it makes sense to have an INDEX created for a fast access. This can be achieved with the `--index` directive which adds the corresponding statement to the table creation (`CREATE TABLE`)