MySQL

Truncated result with MySQL GROUP_CONCAT function

MySQL function group_concat is a powerful tool to concat strings using a custom sperator  :

GROUP_CONCAT([DISTINCT] expr [,expr ...]
[ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] [,col ...]]
[SEPARATOR str_val])

But sometimes the execution result may be truncated because of mysql default setting, so in this case "group_concat_max_len" haveto be changed to a bigger value

SET [GLOBAL | SESSION] group_concat_max_len = val;

Database table history using Schemas and mysql triggers

Assuming that we have to trace every intervention on a database called « stats»

As result we wil have a new database with the "history_" prefix which will contain all the same tables of our source database "stats" but with different column definition. We have to add 3 new colums.

  • Operation.
  • Time.
  • Operation made.

Creating the histroy database.

To continue we assume that the mysql user is having all the correct privilieges for creating databases and Triggers.

Syndicate content