Advertisement
Guest User

Untitled

a guest
Apr 11th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. select concat(
  2. 'mysqldump'
  3. , ' --user=wcm_dwh'
  4. , ' --password=wcm_dwh'
  5. , ' --no-create-info'
  6. , ' --where="'
  7. , case p2.partition_method
  8. when 'hash' then
  9. concat(
  10. p2.partition_expression, ' % '
  11. , (select count(*)
  12. from information_schema.partitions p3
  13. where p3.table_schema = p2.table_schema
  14. and p3.table_name = p2.table_name)
  15. , ' = ', (p2.partition_ordinal_position - 1)
  16. )
  17. when 'list' then
  18. concat(
  19. p2.partition_expression
  20. , ' in (', p2.partition_description, ')'
  21. )
  22. when 'range' then
  23. concat(
  24. coalesce(
  25. concat(
  26. p2.partition_expression
  27. , ' >= '
  28. , p1.partition_description
  29. , ' and '
  30. )
  31. , ''
  32. )
  33. , concat(
  34. p2.partition_expression
  35. , ' < '
  36. , p2.partition_description
  37. )
  38. )
  39. end
  40. , '" ', p2.table_schema
  41. , ' ', p2.table_name
  42. , ' > '
  43. , p2.table_schema, '.', p2.table_name
  44. , '.', p2.partition_name, '.sql'
  45. )
  46. from information_schema.partitions p1
  47. right join information_schema.partitions p2
  48. on p1.table_schema = p2.table_schema
  49. and p1.table_name = p2.table_name
  50. and p1.partition_ordinal_position + 1 = p2.partition_ordinal_position
  51. where p2.table_schema = schema()
  52. and p2.partition_method in ('hash', 'list', 'range')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement