File: mysqldump-header.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (126 lines) | stat: -rw-r--r-- 4,426 bytes parent folder | download | duplicates (2)
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
--source include/not_embedded.inc

SET NAMES utf8mb4;
CREATE TABLE `courses` (
  `course_id` smallint(20) PRIMARY KEY,
  `name` varchar(50),
  `description` varchar(100),
  `num_years` tinyint(1),
  `escape_çÇÁá!#%"'` varchar(10)
);

desc courses;

INSERT INTO `courses` VALUES (5, 'Course 1', 'Course Description 1', 3, NULL);

--echo #
--echo # Dump only data rows into outfile with default options
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows into outfile with default options
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows into outfile with comma delimited fields
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows into outfile with single quote enclosed fields
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-enclosed-by \' test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows into outfile with optional single quote enclosed fields
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-optionally-enclosed-by \' test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows into outfile with semicolon terminated data rows
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --lines-terminated-by \; test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo
--echo #
--echo # Dump header and data rows into outfile with several options above combined
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , --fields-enclosed-by \' --lines-terminated-by \; test
--cat_file $MYSQLTEST_VARDIR/courses.txt
--echo
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , --fields-optionally-enclosed-by \' --lines-terminated-by \; test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo
--echo #
--echo # --skip-quote-names
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --skip-quote-names test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # --compatible=ansi
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --compatible=ansi test
--cat_file $MYSQLTEST_VARDIR/courses.txt

INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL);
INSERT INTO `courses` VALUES (3, 'Course 3', 'Course Description 3', 3, NULL);
INSERT INTO `courses` VALUES (2, 'Course 4', 'Course Description 4', 5, NULL);
INSERT INTO `courses` VALUES (1, 'Course 5', 'Course Description 5', 3, NULL);

--echo
--echo #
--echo # Dump data rows into outfile with --where clause
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --where "num_years=5" test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows into outfile with --where clause. The header must remain on top and not meddle among data rows
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --where "num_years=5" --header test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump data rows ordered by primary key.
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --order-by-primary test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows ordered by primary key. The header must remain on top and not meddle among data rows
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --order-by-primary --header test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump data rows from an empty table, must generate no output
--echo #
DELETE FROM `courses`;
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Dump header and data rows from an empty table, must generate a single header line as output
--echo #
--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header test
--cat_file $MYSQLTEST_VARDIR/courses.txt

--echo #
--echo # Use header without the --tab option. Must produce an error
--echo #
--error 1
--exec $MYSQL_DUMP -u root --header test

DROP TABLE `courses`;
--remove_file $MYSQLTEST_VARDIR/courses.txt
--remove_file $MYSQLTEST_VARDIR/courses.sql