1MYSQLMETAGREP(1)                MySQL Utilities               MYSQLMETAGREP(1)
2
3
4

NAME

6       mysqlmetagrep - Search MySQL servers for objects matching a pattern
7

SYNOPSIS

9          mysqlmetagrep [ --version | --help ] | --format=<format> |
10                 --body  |  --types<object types> | --regexp | --sql | --data‐
11                 base=<pattern>             |              --pattern=<pattern>
12                 --server=<user>[<passwd>]@<host>:[<port>][:<socket>]
13

DESCRIPTION

15       This  utility  searches  for  objects  on  all the servers provided via
16       repeated occurrences of the --server option matching  a  given  pattern
17       and  show a table of the objects that match. The first non-option argu‐
18       ment it taken to be the pattern unless the --pattern option is used, in
19       which  case all non-option arguments are treated as connection specifi‐
20       cations.
21
22       Internally, the utility creates an SQL statement for searching the nec‐
23       essary  tables  in  the  INFORMATION_SCHEMA  database  on  the provided
24       servers and executes it in turn before collecting the result and print‐
25       ing  it  as  a  table.  If you do not want to send the statement to the
26       servers and instead have the utility emit the statement,  you  can  use
27       the  --sql option. This can be useful if you want to feed the output of
28       the statement to other utilities such as mysqlevent(1).
29
30       The MySQL server uses two forms of patterns when matching strings:  SQL
31       Simple Patterns and POSIX Regular Expressions.
32
33       Normally,  the LIKE operator is used to match the name (and optionally,
34       the body) but this can be changed to use the REGEXP operator instead by
35       using the --regexp option.
36
37       Note  that  since the REGEXP operator does a substring searching, it is
38       necessary to anchor the expression to the beginning of  the  string  if
39       you want to match the beginning of the string.
40
41       You  also  have  the  choice to view the output in one of the following
42       formats using the --format option.
43
44       GRID
45
46              Displays output formatted like that of the mysql  monitor  in  a
47              grid or table layout. This is the default.
48
49       CSV
50
51              Displays the output in a comma-separated list.
52
53       TAB
54
55              Displays the output in a tab-separated list.
56
57       VERTICAL
58
59              Displays  the output in a single column similar to the \G option
60              for the mysql monitor commands.
61
62   SQL Simple Patterns
63       The simple patterns defined by SQL standard  consist  of  a  string  of
64       characters  with  two characters that have special meaning: % (percent)
65       matches zero or more characters and _ (underscore) matches exactly  one
66       character.
67
68       For example:
69
70       'mats%'
71
72              Matches any string that starts with 'mats'.
73
74       '%kindahl%'
75
76              Matches any string consisting containing the word 'kindahl'.
77
78       '%_'
79
80              Matches any string consisting of one or more characters.
81
82   POSIX Regular Expressions
83       POSIX  regular  expressions  are more powerful than the simple patterns
84       defined in the SQL standard. A regular expression is a string of  char‐
85       acters, optionally containing characters with special meaning:
86
87       .
88
89              Matches any character.
90
91       ^
92
93              Matches the beginning of a string.
94
95       $
96
97              Matches the end of a string.
98
99       [axy]
100
101              Matches either a, x, or y.
102
103       [a-f]
104
105              Matches  any character in the range a to f (that is, a, b, c, d,
106              e, or f).
107
108       [^axy]
109
110              Matches any character except a, x, or y.
111
112       a*
113
114              Matches a sequence of zero or more a.
115
116       a+
117
118              Matches a sequence of one or more a.
119
120       a?
121
122              Matches zero or one a.
123
124       ab|cd
125
126              Matches either ab or cd.
127
128       a{5}
129
130              Matches 5 instances of a.
131
132       a{2,5}
133
134              Matches between 2 and 5 instances of a.
135
136       (abc)+
137
138              Matches one or more repetitions of abc.
139
140       This is but a brief set of examples of regular  expressions.  The  full
141       syntax  is  described  in  the  MySQL manual, but can often be found in
142       regex(7).
143

OPTIONS

145       --search-objects <type>, ...
146
147       --object-types <type>, ...
148
149              Only search for/in objects of type <type>, where <type> can  be:
150              procedure, function, event, trigger, table, or database.
151
152              Default is to search in objects of all kinds of types.
153
154       --body, -b
155
156              Search  the body of procedures, functions, triggers, and events.
157              Default is to only match the name.
158
159       --regexp, --basic-regexp, -G
160
161              Perform the match using the REGEXP operator. Default is  to  use
162              LIKE for matching.
163
164       --sql, --print-sql, -p
165
166              Print  the  SQL  code that will be executed to find all matching
167              objects. This can be useful if you want to  safe  the  statement
168              for later execution, or pipe it into other tools.
169
170       --pattern <pattern>, -e <pattern>
171
172              Pattern  to use when matching. This is required when the pattern
173              looks like a connection specification.
174
175              If a pattern option is given, the first argument is not  treated
176              as a pattern but as a connection specifier.
177
178       --database <pattern>
179
180              Only look in databases matching this pattern.
181
182       --format <format>, -f <format>
183
184              display the output in either GRID (default), TAB, CSV, or VERTI‐
185              CAL format
186
187       --version
188              Print the version and exit.
189
190       --help, -h
191
192              Print help.
193

EXAMPLES

195       Find all objects where the name match the pattern 't\_':
196
197       $ mysqlmetagrep --pattern="t_" --server=mats@localhost
198       +------------------------+--------------+--------------+-----------+
199       | Connection             | Object Type  | Object Name  | Database  |
200       +------------------------+--------------+--------------+-----------+
201       | mats:*@localhost:3306  | TABLE        | t1           | test      |
202       | mats:*@localhost:3306  | TABLE        | t2           | test      |
203       | mats:*@localhost:3306  | TABLE        | t3           | test      |
204       +------------------------+--------------+--------------+-----------+
205
206       To find all object that contain 't2' in the name or the body (for  rou‐
207       tines, triggers, and events):
208
209       $ mysqlmetagrep -b --pattern="%t2%" --server=mats@localhost:3306
210       +------------------------+--------------+--------------+-----------+
211       | Connection             | Object Type  | Object Name  | Database  |
212       +------------------------+--------------+--------------+-----------+
213       | root:*@localhost:3306  | TRIGGER      | tr_foo       | test      |
214       | root:*@localhost:3306  | TABLE        | t2           | test      |
215       +------------------------+--------------+--------------+-----------+
216
217       Same  thing,  but using the REGEXP operator. Note that it is not neces‐
218       sary to add wildcards before the pattern:
219
220       $ mysqlmetagrep -Gb --pattern="t2" --server=mats@localhost
221       +------------------------+--------------+--------------+-----------+
222       | Connection             | Object Type  | Object Name  | Database  |
223       +------------------------+--------------+--------------+-----------+
224       | root:*@localhost:3306  | TRIGGER      | tr_foo       | test      |
225       | root:*@localhost:3306  | TABLE        | t2           | test      |
226       +------------------------+--------------+--------------+-----------+
227
229       Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
230
231       This program is free software; you can redistribute it and/or modify it
232       under  the  terms of the GNU General Public License as published by the
233       Free Software Foundation; version 2 of the License.
234
235       This program is distributed in the hope that it  will  be  useful,  but
236       WITHOUT  ANY  WARRANTY;  without  even  the  implied  warranty  of MER‐
237       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  General
238       Public License for more details.
239
240       You should have received a copy of the GNU General Public License along
241       with this program; if not, write to the Free Software Foundation, Inc.,
242       51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
243

AUTHOR

245       MySQL Utilities Team
246
248       2010, Oracle and/or its affiliates. All rights reserved.
249
250
251
252
2531.0.1                         September 23, 2011              MYSQLMETAGREP(1)
Impressum