File: mysqldbcompare.1

package info (click to toggle)
mysql-utilities 1.3.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,100 kB
  • ctags: 1,681
  • sloc: python: 19,938; makefile: 34
file content (857 lines) | stat: -rw-r--r-- 21,638 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
'\" t
.\"     Title: \fBmysqldbcompare\fR
.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 08/30/2013
.\"    Manual: MySQL Utilities
.\"    Source: MySQL 1.3.4
.\"  Language: English
.\"
.TH "\FBMYSQLDBCOMPARE\FR" "1" "08/30/2013" "MySQL 1\&.3\&.4" "MySQL Utilities"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.\" mysqldbcompare
.\" utilities: mysqldbcompare
.\" scripts
.SH "NAME"
mysqldbcompare \- Compare Two Databases and Identify Differences
.SH "SYNOPSIS"
.HP \w'\fBmysqldbcompare\ [\fR\fB\fIoptions\fR\fR\fB]\ \fR\fB\fIdb1\fR\fR\fB\ [\fR\fB\fI:db2\fR\fR\fB]\ \&.\&.\&.\fR\ 'u
\fBmysqldbcompare [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb1\fR\fR\fB [\fR\fB\fI:db2\fR\fR\fB] \&.\&.\&.\fR
.SH "DESCRIPTION"
.PP
This utility compares the objects and data from two databases to find differences\&. It identifies objects having different definitions in the two databases and presents them in a diff\-style format of choice\&. Differences in the data are shown using a similar diff\-style format\&. Changed or missing rows are shown in a standard format of GRID, CSV, TAB, or VERTICAL\&.
.PP
Use the notation db1:db2 to name two databases to compare, or, alternatively just db1 to compare two databases with the same name\&. The latter case is a convenience notation for comparing same\-named databases on different servers\&.
.PP
The comparison may be run against two databases of different names on a single server by specifying only the
\fB\-\-server1\fR
option\&. The user can also connect to another server by specifying the
\fB\-\-server2\fR
option\&. In this case, db1 is taken from server1 and db2 from server2\&.
.PP
Those objects considered in the database include tables, views, triggers, procedures, functions, and events\&. A count for each object type can be shown with the
\fB\-vv\fR
option\&.
.PP
The check is performed using a series of steps called tests\&. By default, the utility stops on the first failed test, but you can specify the
\fB\-\-run\-all\-tests\fR
option to cause the utility to run all tests regardless of their end state\&.
.PP
Note: Using
\fB\-\-run\-all\-tests\fR
may produce expected cascade failures\&. For example, if the row counts differ among two tables being compared, the data consistency will also fail\&.
.PP
The tests include the following:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  1." 4.2
.\}
Check database definitions
.sp
A database existence precondition check ensures that both databases exist\&. If they do not, no further processing is possible and the
\fB\-\-run\-all\-tests\fR
option is ignored\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  2." 4.2
.\}
Check existence of objects in both databases
.sp
The test for objects in both databases identifies those objects missing from one or another database\&. The remaining tests apply only to those objects that appear in both databases\&. To skip this test, use the
\fB\-\-skip\-object\-compare\fR
option\&. That can be useful when there are known missing objects among the databases\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  3." 4.2
.\}
Compare object definitions
.sp
The definitions (the
\fBCREATE\fR
statements) are compared and differences are presented\&. To skip this test, use the
\fB\-\-skip\-diff\fR
option\&. That can be useful when there are object name differences only that you want to ignore\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 4.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  4." 4.2
.\}
Check table row counts
.sp
This check ensures that both tables have the same number of rows\&. This does not ensure that the table data is consistent\&. It is merely a cursory check to indicate possible missing rows in one table or the other\&. The data consistency check identifies the missing rows\&. To skip this test, use the
\fB\-\-skip\-row\-count\fR
option\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 5.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  5." 4.2
.\}
Check table data consistency
.sp
This check identifies both changed rows as well as missing rows from one or another of the tables in the databases\&. Changed rows are displayed as a diff\-style report with the format chosen (\fBGRID\fR
by default) and missing rows are also displayed using the format chosen\&. To skip this test, use the
\fB\-\-skip\-data\-check\fR
option\&.
.RE
.PP
You may want to use the
\-\-skip\-xxx
options to run only one of the tests\&. This might be helpful when working to bring two databases into synchronization, to avoid running all of the tests repeatedly during the process\&.
.PP
Each test completes with one of the following states:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBpass\fR
.sp
The test succeeded\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBFAIL\fR
.sp
The test failed\&. Errors are displayed following the test state line\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBSKIP\fR
.sp
The test was skipped due to a missing prerequisite or a skip option\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBWARN\fR
.sp
The test encountered an unusual but not fatal error\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\fR
.sp
The test is not applicable to this object\&.
.RE
.PP
To specify how to display diff\-style output, use one of the following values with the
\fB\-\-difftype\fR
option:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBunified\fR
(default)
.sp
Display unified format output\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBcontext\fR
.sp
Display context format output\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBdiffer\fR
.sp
Display differ\-style format output\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBsql\fR
.sp
Display SQL transformation statement output\&.
.RE
.PP
To specify how to display output for changed or missing rows, use one of the following values with the
\fB\-\-format\fR
option:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBgrid\fR
(default)
.sp
Display output in grid or table format like that of the
\fBmysql\fR
monitor\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBcsv\fR
.sp
Display output in comma\-separated values format\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBtab\fR
.sp
Display output in tab\-separated format\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBvertical\fR
.sp
Display output in single\-column format like that of the
\eG
command for the
\fBmysql\fR
monitor\&.
.RE
.PP
The
\fB\-\-changes\-for\fR
option controls the direction of the difference (by specifying the object to be transformed) in either the difference report (default) or the transformation report (designated with the
\fB\-\-difftype=sql\fR
option)\&. Consider the following command:
.sp
.if n \{\
.RS 4
.\}
.nf
mysqldbcompare \-\-server1=root@host1 \-\-server2=root@host2 \-\-difftype=sql \e
  db1:dbx
.fi
.if n \{\
.RE
.\}
.PP
The leftmost database (db1) exists on the server designated by the
\fB\-\-server1\fR
option (host1)\&. The rightmost database (dbx) exists on the server designated by the
\fB\-\-server2\fR
option (host2)\&.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-changes\-for=server1\fR: Produce output that shows how to make the definitions of objects on
server1
like the definitions of the corresponding objects on
server2\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-changes\-for=server2\fR: Produce output that shows how to make the definitions of objects on
server2
like the definitions of the corresponding objects on
server1\&.
.RE
.PP
The default direction is
server1\&.
.PP
You must provide connection parameters (user, host, password, and so forth) for an account that has the appropriate privileges to access all objects in the operation\&.
.PP
If the utility is to be run on a server that has binary logging enabled, and you do not want the comparison steps logged, use the
\fB\-\-disable\-binary\-logging\fR
option\&.
      OPTIONS
.PP
\fBmysqldbcompare\fR
accepts the following command\-line options:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-help
.sp
Display a help message and exit\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-changes\-for=<direction>
.sp
Specify the server to show transformations to match the other server\&. For example, to see the transformation for transforming object definitions on server1 to match the corresponding definitions on server2, use
\fB\-\-changes\-for=server1\fR\&. Permitted values are
\fBserver1\fR
and
\fBserver2\fR\&. The default is
\fBserver1\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-difftype=<difftype>, \-d<difftype>
.sp
Specify the difference display format\&. Permitted format values are
\fBunified\fR,
\fBcontext\fR,
\fBdiffer\fR, and
\fBsql\fR\&. The default is
\fBunified\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-disable\-binary\-logging
.sp
If binary logging is enabled, disable it during the operation to prevent comparison operations from being written to the binary log\&. Note: Disabling binary logging requires the
\fBSUPER\fR
privilege\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-format=<format>, \-f<format>
.sp
Specify the display format for changed or missing rows\&. Permitted format values are
\fBgrid\fR,
\fBcsv\fR,
\fBtab\fR, and
\fBvertical\fR\&. The default is
\fBgrid\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-quiet, \-q
.sp
Do not print anything\&. Return only an exit code of success or failure\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-run\-all\-tests, \-a
.sp
Do not halt at the first difference found\&. Process all objects\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-server1=<source>
.sp
Connection information for the first server in the format: <\fIuser\fR>[:<\fIpasswd\fR>]@<\fIhost\fR>[:<\fIport\fR>][:<\fIsocket\fR>] or <\fIlogin\-path\fR>[:<\fIport\fR>][:<\fIsocket\fR>]\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-server2=<source>
.sp
Connection information for the second server in the format: <\fIuser\fR>[:<\fIpasswd\fR>]@<\fIhost\fR>[:<\fIport\fR>][:<\fIsocket\fR>] or <\fIlogin\-path\fR>[::<\fIport\fR>][::<\fIsocket\fR>]\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-show\-reverse
.sp
Produce a transformation report containing the SQL statements to conform the object definitions specified in reverse\&. For example, if \-\-changes\-for is set to server1, also generate the transformation for server2\&. Note: The reverse changes are annotated and marked as comments\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip\-data\-check
.sp
Skip the data consistency check\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip\-diff
.sp
Skip the object definition difference check\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip\-object\-compare
.sp
Skip the object comparison check\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip\-row\-count
.sp
Skip the row count check\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-span\-key\-size=<number of bytes to use for key>
.sp
Change the size of the key used for compare table contents\&. A higher value can help to get more accurate results comparing large databases, but may slow the algorithm\&.
.sp
Default value is 8\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-verbose, \-v
.sp
Specify how much information to display\&. Use this option multiple times to increase the amount of information\&. For example,
\fB\-v\fR
= verbose,
\fB\-vv\fR
= more verbose,
\fB\-vvv\fR
= debug\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-version
.sp
Display version information and exit\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-width=<number>
.sp
Change the display width of the test report\&. The default is 75 characters\&.
.RE
      NOTES
.PP
The login user must have the appropriate permissions to read all databases and tables listed\&.
.PP
For the
\fB\-\-difftype\fR
option, the permitted values are not case sensitive\&. In addition, values may be specified as any unambiguous prefix of a valid value\&. For example,
\fB\-\-difftype=d\fR
specifies the differ type\&. An error occurs if a prefix matches more than one valid value\&.
.PP
The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login\-paths\&. This will allow the utility to use the my_print_defaults tools which is required to read the login\-path values from the login configuration file (\&.mylogin\&.cnf)\&.
.PP
If any database identifier specified as an argument contains special characters or is a reserved word, then it must be appropriately quoted with backticks (\fB`\fR)\&. In turn, names quoted with backticks must also be quoted with single or double quotes depending on the operating system, i\&.e\&. (\fB"\fR) in Windows or (\fB\*(Aq\fR) in non\-Windows systems, in order for the utilities to read backtick quoted identifiers as a single argument\&. For example, to compare a database with the name
\fBweird`db\&.name\fR
with
\fBother:weird`db\&.name\fR, the database pair must be specified using the following syntax (in non\-Windows):
\fB\*(Aq`weird``db\&.name`:`other:weird``db\&.name`\*(Aq\fR\&.
      EXAMPLES
.PP
Use the following command to compare the
emp1
and
emp2
databases on the local server, and run all tests even if earlier tests fail:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbcompare \-\-server1=root@localhost emp1:emp2 \-\-run\-all\-tests
# server1 on localhost: \&.\&.\&. connected\&.
# Checking databases emp1 on server1 and emp2 on server2
WARNING: Objects in server2:emp2 but not in server1:emp1:
  TRIGGER: trg
PROCEDURE: p1
    TABLE: t1
     VIEW: v1
                                                    Defn    Row     Data
Type      Object Name                               Diff    Count   Check
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
FUNCTION  f1                                        pass    \-       \-
TABLE     departments                               pass    pass    FAIL
Data differences found among rows:
\-\-\- emp1\&.departments
+++ emp2\&.departments
@@ \-1,4 +1,4 @@
 *************************       1\&. row *************************
    dept_no: d002
\- dept_name: dunno
+ dept_name: Finance
 1 rows\&.
Rows in emp1\&.departments not in emp2\&.departments
*************************       1\&. row *************************
   dept_no: d008
 dept_name: Research
1 rows\&.
Rows in emp2\&.departments not in emp1\&.departments
*************************       1\&. row *************************
   dept_no: d100
 dept_name: stupid
1 rows\&.
TABLE     dept_manager                              pass    pass    pass
Database consistency check failed\&.
# \&.\&.\&.done
.fi
.if n \{\
.RE
.\}
.PP
Given: two databases with the same table layout\&. Data for each table contains:
.sp
.if n \{\
.RS 4
.\}
.nf
mysql> select * from db1\&.t1;
+\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| a | b             |
+\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| 1 | Test 789      |
| 2 | Test 456      |
| 3 | Test 123      |
| 4 | New row \- db1 |
+\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
4 rows in set (0\&.00 sec)
mysql> select * from db2\&.t1;
+\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| a | b             |
+\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
| 1 | Test 123      |
| 2 | Test 456      |
| 3 | Test 789      |
| 5 | New row \- db2 |
+\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
4 rows in set (0\&.00 sec)
.fi
.if n \{\
.RE
.\}
.PP
To generate the SQL statements for data transformations to make
db1\&.t1
the same as
db2\&.t1, use the
\fB\-\-changes\-for=server1\fR
option\&. We must also include the
\fB\-a\fR
option to ensure that the data consistency test is run\&. The following command illustrates the options used and an excerpt from the results generated:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbcompare \-\-server1=root:root@localhost \e
    \-\-server2=root:root@localhost db1:db2 \-\-changes\-for=server1 \-a \e
    \-\-difftype=sql
[\&.\&.\&.]
#                                                   Defn    Row     Data
# Type      Object Name                             Diff    Count
Check #
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
# TABLE     t1                                      pass    pass    FAIL
# # Data transformations for direction = server1:
# Data differences found among rows: UPDATE db1\&.t1 SET b = \*(AqTest 123\*(Aq
WHERE a = \*(Aq1\*(Aq; UPDATE db1\&.t1 SET b = \*(AqTest 789\*(Aq WHERE a = \*(Aq3\*(Aq; DELETE
FROM db1\&.t1 WHERE a = \*(Aq4\*(Aq; INSERT INTO db1\&.t1 (a, b) VALUES(\*(Aq5\*(Aq, \*(AqNew
row \- db2\*(Aq);
# Database consistency check failed\&.  # # \&.\&.\&.done
.fi
.if n \{\
.RE
.\}
.PP
Similarly, when the same command is run with
\fB\-\-changes\-for=server2\fR
and
\fB\-\-difftype=sql\fR, the following report is generated:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbcompare \-\-server1=root:root@localhost \e
    \-\-server2=root:root@localhost db1:db2 \-\-changes\-for=server2 \-a \e
    \-\-difftype=sql
[\&.\&.\&.]
#                                                   Defn    Row     Data
# Type      Object Name                             Diff    Count
Check #
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
# TABLE     t1                                      pass    pass    FAIL
# # Data transformations for direction = server2:
# Data differences found among rows: UPDATE db2\&.t1 SET b = \*(AqTest 789\*(Aq
WHERE a = \*(Aq1\*(Aq; UPDATE db2\&.t1 SET b = \*(AqTest 123\*(Aq WHERE a = \*(Aq3\*(Aq; DELETE
FROM db2\&.t1 WHERE a = \*(Aq5\*(Aq; INSERT INTO db2\&.t1 (a, b) VALUES(\*(Aq4\*(Aq, \*(AqNew
row \- db1\*(Aq);
.fi
.if n \{\
.RE
.\}
.PP
With the
\fB\-\-difftype=sql\fR
SQL generation option set,
\fB\-\-show\-reverse\fR
shows the object transformations in both directions\&. Here is an excerpt of the results:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbcompare \-\-server1=root:root@localhost \e
\-\-server2=root:root@localhost db1:db2 \-\-changes\-for=server1 \e
\-\-show\-reverse \-a \-\-difftype=sql
[\&.\&.\&.]
#                                                   Defn    Row     Data
# Type      Object Name                             Diff    Count
Check #
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
# TABLE     t1                                      pass    pass    FAIL
# # Data transformations for direction = server1:
# Data differences found among rows: UPDATE db1\&.t1 SET b = \*(AqTest 123\*(Aq
WHERE a = \*(Aq1\*(Aq; UPDATE db1\&.t1 SET b = \*(AqTest 789\*(Aq WHERE a = \*(Aq3\*(Aq; DELETE
FROM db1\&.t1 WHERE a = \*(Aq4\*(Aq; INSERT INTO db1\&.t1 (a, b) VALUES(\*(Aq5\*(Aq, \*(AqNew
row \- db2\*(Aq);
# Data transformations for direction = server2:
# Data differences found among rows: UPDATE db2\&.t1 SET b = \*(AqTest 789\*(Aq
WHERE a = \*(Aq1\*(Aq; UPDATE db2\&.t1 SET b = \*(AqTest 123\*(Aq WHERE a = \*(Aq3\*(Aq; DELETE
FROM db2\&.t1 WHERE a = \*(Aq5\*(Aq; INSERT INTO db2\&.t1 (a, b) VALUES(\*(Aq4\*(Aq, \*(AqNew
row \- db1\*(Aq);
# Database consistency check failed\&.  # # \&.\&.\&.done
.fi
.if n \{\
.RE
.\}
.SH "COPYRIGHT"
.br
.SH "SEE ALSO"
For more information, please refer to the MySQL Utilities section
of the MySQL Workbench Reference Manual, which is available online
at http://dev.mysql.com/doc/workbench/en/.
.SH AUTHOR
Oracle Corporation (http://dev.mysql.com/).