.TH "MYSQLMETAGREP" "1" "May 09, 2012" "1.0.3" "MySQL Utilities" .SH NAME mysqlmetagrep \- Search MySQL servers for objects matching a pattern . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .\" Man page generated from reStructeredText. . .SH SYNOPSIS .sp .nf .ft C mysqlmetagrep [options] [pattern | server] ... .ft P .fi .SH DESCRIPTION .sp This utility searches for objects matching a given pattern on all the servers specified using instances of the \fI\-\-server\fP option. It produces output that displays the matching objects. By default, the first nonoption argument is taken to be the pattern unless the \fI\%--pattern\fP option is given. If the \fI\%--pattern\fP option is given, all nonoption arguments are treated as connection specifications. .sp Internally, the utility generates an SQL statement for searching the necessary tables in the \fBINFORMATION_SCHEMA\fP database on the designated servers and executes it in turn before collecting the result and printing it as a table. Use the \fI\-\-sql\fP option to have the utility display the statement rather than execute it. This can be useful if you want to feed the output of the statement to another application such as the \fBmysql\fP monitor. .sp The MySQL server supports two forms of patterns when matching strings: \fI\%SQL Simple Patterns\fP (used with the \fBLIKE\fP operator) and \fI\%POSIX Regular Expressions\fP (used with the \fBREGEXP\fP operator). .sp By default, the utility uses the \fBLIKE\fP operator to match the name (and optionally, the body) of objects. To use the \fBREGEXP\fP operator instead, use the \fI\-\-regexp\fP option. .sp Note that since the \fBREGEXP\fP operator does substring searching, it is necessary to anchor the expression to the beginning of the string if you want to match the beginning of the string. .sp To specify how to display output, use one of the following values with the \fI\-\-format\fP option: .INDENT 0.0 .TP .B \fBgrid\fP (default) Display output in grid or table format like that of the \fBmysql\fP monitor. .TP .B \fBcsv\fP Display output in comma\-separated values format. .TP .B \fBtab\fP Display output in tab\-separated format. .TP .B \fBvertical\fP Display output in single\-column format like that of the \fB\eG\fP command for the \fBmysql\fP monitor. .UNINDENT .SS SQL Simple Patterns .sp The simple patterns defined by the SQL standard consist of a string of characters with two characters that have special meaning: \fB%\fP (percent) matches zero or more characters and \fB_\fP (underscore) matches exactly one character. .sp For example: .INDENT 0.0 .TP .B \fB\(aqmats%\(aq\fP Match any string that starts with \(aqmats\(aq. .TP .B \fB\(aq%kindahl%\(aq\fP Match any string containing the word \(aqkindahl\(aq. .TP .B \fB\(aq%_\(aq\fP Match any string consisting of one or more characters. .UNINDENT .SS POSIX Regular Expressions .sp POSIX regular expressions are more powerful than the simple patterns defined in the SQL standard. A regular expression is a string of characters, optionally containing characters with special meaning: .INDENT 0.0 .TP .B \fB.\fP Match any character. .TP .B \fB^\fP Match the beginning of a string. .TP .B \fB$\fP Match the end of a string. .TP .B \fB[axy]\fP Match \fBa\fP, \fBx\fP, or \fBy\fP. .TP .B \fB[a\-f]\fP Match any character in the range \fBa\fP to \fBf\fP (that is, \fBa\fP, \fBb\fP, \fBc\fP, \fBd\fP, \fBe\fP, or \fBf\fP). .TP .B \fB[^axy]\fP Match any character \fIexcept\fP \fBa\fP, \fBx\fP, or \fBy\fP. .TP .B \fBa*\fP Match a sequence of zero or more \fBa\fP. .TP .B \fBa+\fP Match a sequence of one or more \fBa\fP. .TP .B \fBa?\fP Match zero or one \fBa\fP. .TP .B \fBab|cd\fP Match \fBab\fP or \fBcd\fP. .TP .B \fBa{5}\fP Match five instances of \fBa\fP. .TP .B \fBa{2,5}\fP Match from two to five instances of \fBa\fP. .TP .B \fB(abc)+\fP Match one or more repetitions of \fBabc\fP. .UNINDENT .sp This is but a brief set of examples of regular expressions. The full syntax is described in the \fI\%MySQL manual\fP, but can often be found in \fIregex(7)\fP. .SH OPTIONS .sp \fBmysqlmetagrep\fP accepts the following command\-line options: .INDENT 0.0 .TP .B \-\-help Display a help message and exit. .UNINDENT .INDENT 0.0 .TP .B \-\-body, \-b Search the body of stored programs (procedures, functions, triggers, and events). The default is to match only the name. .UNINDENT .INDENT 0.0 .TP .B \-\-database= Look only in databases matching this pattern. .UNINDENT .INDENT 0.0 .TP .B \-\-format=, \-f Specify the output display format. Permitted format values are \fBgrid\fP, \fBcsv\fP, \fBtab\fP, and \fBvertical\fP. The default is \fBgrid\fP. .UNINDENT .INDENT 0.0 .TP .B \-\-object\-types=, \-\-search\-objects= Search only the object types named in \fItypes\fP, which is a comma\-separated list of one or more of the values \fBprocedure\fP, \fBfunction\fP, \fBevent\fP, \fBtrigger\fP, \fBtable\fP, and \fBdatabase\fP. .sp The default is to search in objects of all types. .UNINDENT .INDENT 0.0 .TP .B \-\-pattern=, \-e= The pattern to use when matching. This is required when the first nonoption argument looks like a connection specification rather than a pattern. .sp If the \fI\%--pattern\fP option is given, the first nonoption argument is treated as a connection specifier, not as a pattern. .UNINDENT .INDENT 0.0 .TP .B \-\-regexp, \-\-basic\-regexp, \-G Perform pattern matches using the \fBREGEXP\fP operator. The default is to use \fBLIKE\fP for matching. This affects the \fI\%--database\fP and \fI\%--pattern\fP options. .UNINDENT .INDENT 0.0 .TP .B \-\-server= Connection information for a server to search in <\fIuser\fP>[:<\fIpasswd\fP>]@<\fIhost\fP>[:<\fIport\fP>][:<\fIsocket\fP>] format. Use this option multiple times to search multiple servers. .UNINDENT .INDENT 0.0 .TP .B \-\-sql, \-\-print\-sql, \-p Print rather than executing the SQL code that would be executed to find all matching objects. This can be useful to save the statement for later execution or to use it as input for other programs. .UNINDENT .INDENT 0.0 .TP .B \-\-version Display version information and exit. .UNINDENT .SH NOTES .sp For the \fI\-\-format\fP option, the permitted values are not case sensitive. In addition, values may be specified as any unambiguous prefix of a valid value. For example, \fI\-\-format=g\fP specifies the grid format. An error occurs if a prefix matches more than one valid value. .SH EXAMPLES .sp Find all objects with a name that matches the pattern \fB\(aqt_\(aq\fP (the letter t followed by any single character): .sp .nf .ft C $ mysqlmetagrep \-\-pattern="t_" \-\-server=mats@localhost +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ | Connection | Object Type | Object Name | Database | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ | mats:*@localhost:3306 | TABLE | t1 | test | | mats:*@localhost:3306 | TABLE | t2 | test | | mats:*@localhost:3306 | TABLE | t3 | test | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ .ft P .fi .sp To find all object that contain \fB\(aqt2\(aq\fP in the name or the body (for routines, triggers, and events): .sp .nf .ft C $ mysqlmetagrep \-b \-\-pattern="%t2%" \-\-server=mats@localhost:3306 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ | Connection | Object Type | Object Name | Database | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ | root:*@localhost:3306 | TRIGGER | tr_foo | test | | root:*@localhost:3306 | TABLE | t2 | test | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ .ft P .fi .sp In the preceding output, the trigger name does not match the pattern, but is displayed because its body does. .sp This is the same as the previous example, but using the \fBREGEXP\fP operator. Note that in the pattern it is not necessary to add wildcards before or after t2: .sp .nf .ft C $ mysqlmetagrep \-Gb \-\-pattern="t2" \-\-server=mats@localhost +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ | Connection | Object Type | Object Name | Database | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ | root:*@localhost:3306 | TRIGGER | tr_foo | test | | root:*@localhost:3306 | TABLE | t2 | test | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ .ft P .fi .SH COPYRIGHT .sp Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. .sp This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. .sp This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. .sp You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110\-1301 USA .SH AUTHOR MySQL Utilities Team .SH COPYRIGHT 2010, Oracle and/or its affiliates. All rights reserved. .\" Generated by docutils manpage writer. .\" .