mysqldump: How to ensure order of tables content in generated txt files











up vote
0
down vote

favorite












I run mysqldump on a before and after picture of database before tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db1 statsdb


and after tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db2 statsdb


So then i do a diff



diff --brief /data/tmp/db1 /data/tmp/db2
Files /data/tmp/db1/details.txt and
/data/tmp/db2/details.txt differ


The trouble is that it results in the txt files, despite having same data created in the db1 and db2 directories do not display the lines in the same order.



Is there a way to force them to sort correctly? Here is the differing files for the record



[root@server ~]# cat /data/tmp/db2/enm_network_element_details.txt
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158

[root@server~]# cat /data/tmp/db1/enm_network_element_details.txt
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0









share|improve this question
























  • SQL tables do not have an intrinsic order because you can order the records when you query them. There is no point in comparing unordered sets.
    – Shadow
    Nov 19 at 15:48










  • Again, what problem does it cause that the items are in a different order in the two files? After importing these two files into any sql database, you can specify your own ordering of the resultset on the fly.
    – Shadow
    Nov 19 at 16:44















up vote
0
down vote

favorite












I run mysqldump on a before and after picture of database before tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db1 statsdb


and after tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db2 statsdb


So then i do a diff



diff --brief /data/tmp/db1 /data/tmp/db2
Files /data/tmp/db1/details.txt and
/data/tmp/db2/details.txt differ


The trouble is that it results in the txt files, despite having same data created in the db1 and db2 directories do not display the lines in the same order.



Is there a way to force them to sort correctly? Here is the differing files for the record



[root@server ~]# cat /data/tmp/db2/enm_network_element_details.txt
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158

[root@server~]# cat /data/tmp/db1/enm_network_element_details.txt
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0









share|improve this question
























  • SQL tables do not have an intrinsic order because you can order the records when you query them. There is no point in comparing unordered sets.
    – Shadow
    Nov 19 at 15:48










  • Again, what problem does it cause that the items are in a different order in the two files? After importing these two files into any sql database, you can specify your own ordering of the resultset on the fly.
    – Shadow
    Nov 19 at 16:44













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I run mysqldump on a before and after picture of database before tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db1 statsdb


and after tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db2 statsdb


So then i do a diff



diff --brief /data/tmp/db1 /data/tmp/db2
Files /data/tmp/db1/details.txt and
/data/tmp/db2/details.txt differ


The trouble is that it results in the txt files, despite having same data created in the db1 and db2 directories do not display the lines in the same order.



Is there a way to force them to sort correctly? Here is the differing files for the record



[root@server ~]# cat /data/tmp/db2/enm_network_element_details.txt
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158

[root@server~]# cat /data/tmp/db1/enm_network_element_details.txt
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0









share|improve this question















I run mysqldump on a before and after picture of database before tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db1 statsdb


and after tests



mysqldump --no-create-info --no-create-db  --tab=/data/tmp/db2 statsdb


So then i do a diff



diff --brief /data/tmp/db1 /data/tmp/db2
Files /data/tmp/db1/details.txt and
/data/tmp/db2/details.txt differ


The trouble is that it results in the txt files, despite having same data created in the db1 and db2 directories do not display the lines in the same order.



Is there a way to force them to sort correctly? Here is the differing files for the record



[root@server ~]# cat /data/tmp/db2/enm_network_element_details.txt
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158

[root@server~]# cat /data/tmp/db1/enm_network_element_details.txt
2018-09-26 1 RadioNode 17Q4-R25A12 160 160 160
160 158
2018-09-26 1 RadioNode 17B-R6A19 550 550 550
550 0
2018-09-26 1 RNC 18.Q1-V.12.40 1 1 1 0
0
2018-09-26 1 MGW 17A-C.1.267 15 15 15 15
0
2018-09-26 1 ERBS 17.Q4-J.1.160 480 480 475 480
479
2018-09-26 1 MTAS MTAS-1.5 10 10 10 10
0
2018-09-26 1 SIU02 17A 56 56 56 54 0
2018-09-26 1 Router6672 R17B-GA 1 1 1 0
0
2018-09-26 1 SGSN-MME 16A-CP09 14 14 14
14 0
2018-09-26 1 RNC 17B-V.9.1240 1 1 1 1
0
2018-09-26 1 RBS 18.Q1-U.4.750 350 350 350 350
0
2018-09-26 1 Router6672 R18A-GA 104 104 104 104
0
2018-09-26 1 MINI-LINK-Indoor M16A-TN-5.4FP-L 18 18
18 5 5
2018-09-26 1 EPG 16B-R13C 6 6 6 6
0
2018-09-26 1 ERBS 18.Q1-J.1.220 1 0 0 0
0
2018-09-26 1 MINI-LINK-6352 M17B-6352-2.8 15 15 15
15 0
2018-09-26 1 MINI-LINK-Indoor M17.Q4-TN-6.1-L 41 41
41 4 4
2018-09-26 1 MINI-LINK-Indoor M17A-TN-6.0-LH- 9 9
9 9 9
2018-09-26 1 TCU02 17A 56 56 56 54 0
2018-09-26 1 DSC 17B-R1A 10 10 10 10 0






mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 17:43









Andy Lester

66.1k1279135




66.1k1279135










asked Nov 19 at 15:13









Gill

62




62












  • SQL tables do not have an intrinsic order because you can order the records when you query them. There is no point in comparing unordered sets.
    – Shadow
    Nov 19 at 15:48










  • Again, what problem does it cause that the items are in a different order in the two files? After importing these two files into any sql database, you can specify your own ordering of the resultset on the fly.
    – Shadow
    Nov 19 at 16:44


















  • SQL tables do not have an intrinsic order because you can order the records when you query them. There is no point in comparing unordered sets.
    – Shadow
    Nov 19 at 15:48










  • Again, what problem does it cause that the items are in a different order in the two files? After importing these two files into any sql database, you can specify your own ordering of the resultset on the fly.
    – Shadow
    Nov 19 at 16:44
















SQL tables do not have an intrinsic order because you can order the records when you query them. There is no point in comparing unordered sets.
– Shadow
Nov 19 at 15:48




SQL tables do not have an intrinsic order because you can order the records when you query them. There is no point in comparing unordered sets.
– Shadow
Nov 19 at 15:48












Again, what problem does it cause that the items are in a different order in the two files? After importing these two files into any sql database, you can specify your own ordering of the resultset on the fly.
– Shadow
Nov 19 at 16:44




Again, what problem does it cause that the items are in a different order in the two files? After importing these two files into any sql database, you can specify your own ordering of the resultset on the fly.
– Shadow
Nov 19 at 16:44












1 Answer
1






active

oldest

votes

















up vote
0
down vote













The option "--order-by-primary" might be what you need.

Source: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#mysqldump-option-summary






share|improve this answer





















  • Tried same but still get different orders in both files, edited question to show you what it looks like
    – Gill
    Nov 19 at 16:20










  • Though they look exactly the same. What about sorting the txt files with sort command before running the diff? Or what about comparing the tables in SQL?
    – FloT
    Nov 19 at 16:43













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377563%2fmysqldump-how-to-ensure-order-of-tables-content-in-generated-txt-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













The option "--order-by-primary" might be what you need.

Source: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#mysqldump-option-summary






share|improve this answer





















  • Tried same but still get different orders in both files, edited question to show you what it looks like
    – Gill
    Nov 19 at 16:20










  • Though they look exactly the same. What about sorting the txt files with sort command before running the diff? Or what about comparing the tables in SQL?
    – FloT
    Nov 19 at 16:43

















up vote
0
down vote













The option "--order-by-primary" might be what you need.

Source: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#mysqldump-option-summary






share|improve this answer





















  • Tried same but still get different orders in both files, edited question to show you what it looks like
    – Gill
    Nov 19 at 16:20










  • Though they look exactly the same. What about sorting the txt files with sort command before running the diff? Or what about comparing the tables in SQL?
    – FloT
    Nov 19 at 16:43















up vote
0
down vote










up vote
0
down vote









The option "--order-by-primary" might be what you need.

Source: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#mysqldump-option-summary






share|improve this answer












The option "--order-by-primary" might be what you need.

Source: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#mysqldump-option-summary







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 15:42









FloT

425




425












  • Tried same but still get different orders in both files, edited question to show you what it looks like
    – Gill
    Nov 19 at 16:20










  • Though they look exactly the same. What about sorting the txt files with sort command before running the diff? Or what about comparing the tables in SQL?
    – FloT
    Nov 19 at 16:43




















  • Tried same but still get different orders in both files, edited question to show you what it looks like
    – Gill
    Nov 19 at 16:20










  • Though they look exactly the same. What about sorting the txt files with sort command before running the diff? Or what about comparing the tables in SQL?
    – FloT
    Nov 19 at 16:43


















Tried same but still get different orders in both files, edited question to show you what it looks like
– Gill
Nov 19 at 16:20




Tried same but still get different orders in both files, edited question to show you what it looks like
– Gill
Nov 19 at 16:20












Though they look exactly the same. What about sorting the txt files with sort command before running the diff? Or what about comparing the tables in SQL?
– FloT
Nov 19 at 16:43






Though they look exactly the same. What about sorting the txt files with sort command before running the diff? Or what about comparing the tables in SQL?
– FloT
Nov 19 at 16:43




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377563%2fmysqldump-how-to-ensure-order-of-tables-content-in-generated-txt-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Tonle Sap (See)

I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

Guatemaltekische Davis-Cup-Mannschaft