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
|
'\" t
.\" Title: \fBmysqlmetagrep\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 "\FBMYSQLMETAGREP\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 *
.\" -----------------------------------------------------------------
.\" mysqlmetagrep
.\" utilities: mysqlmetagrep
.\" scripts
.SH "NAME"
mysqlmetagrep \- Search Database Object Definitions
.SH "SYNOPSIS"
.HP \w'\fBmysqlmetagrep\ [\fR\fB\fIoptions\fR\fR\fB]\ [\fR\fB\fIpattern\fR\fR\fB\ |\ \fR\fB\fIserver\fR\fR\fB]\ \&.\&.\&.\fR\ 'u
\fBmysqlmetagrep [\fR\fB\fIoptions\fR\fR\fB] [\fR\fB\fIpattern\fR\fR\fB | \fR\fB\fIserver\fR\fR\fB] \&.\&.\&.\fR
.SH "DESCRIPTION"
.PP
This utility searches for objects matching a given pattern on all the servers specified using instances of the
\fB\-\-server\fR
option\&. It produces output that displays the matching objects\&. By default, the first nonoption argument is taken to be the pattern unless the
\fB\-\-pattern\fR
option is given\&. If the
\fB\-\-pattern\fR
option is given, all nonoption arguments are treated as connection specifications\&.
.PP
Internally, the utility generates an SQL statement for searching the necessary tables in the
\fBINFORMATION_SCHEMA\fR
database on the designated servers and executes it in turn before collecting the result and printing it as a table\&. Use the
\fB\-\-sql\fR
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\fR
monitor\&.
.PP
The MySQL server supports two forms of patterns when matching strings: SQL Simple Patterns (used with the
\fBLIKE\fR
operator) and POSIX Regular Expressions (used with the
\fBREGEXP\fR
operator)\&.
.PP
By default, the utility uses the
\fBLIKE\fR
operator to match the name (and optionally, the body) of objects\&. To use the
\fBREGEXP\fR
operator instead, use the
\fB\-\-regexp\fR
option\&.
.PP
Note that since the
\fBREGEXP\fR
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\&.
.PP
To specify how to display output, 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
SQL Simple Patterns
.PP
The simple patterns defined by the SQL standard consist of a string of characters with two characters that have special meaning:
%
(percent) matches zero or more characters and
_
(underscore) matches exactly one character\&.
.PP
For example:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\*(Aqmats%\*(Aq
.sp
Match any string that starts with \*(Aqmats\*(Aq\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\*(Aq%kindahl%\*(Aq
.sp
Match any string containing the word \*(Aqkindahl\*(Aq\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\*(Aq%_\*(Aq
.sp
Match any string consisting of one or more characters\&.
.RE
POSIX Regular Expressions
.PP
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:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\&.\fR
.sp
Match any character\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB^\fR
.sp
Match the beginning of a string\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB$\fR
.sp
Match the end of a string\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB[axy]\fR
.sp
Match
\fBa\fR,
\fBx\fR, or
\fBy\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB[a\-f]\fR
.sp
Match any character in the range
\fBa\fR
to
\fBf\fR
(that is,
\fBa\fR,
\fBb\fR,
\fBc\fR,
\fBd\fR,
\fBe\fR, or
\fBf\fR)\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB[^axy]\fR
.sp
Match any character
\fIexcept\fR\fBa\fR,
\fBx\fR, or
\fBy\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBa*\fR
.sp
Match a sequence of zero or more
\fBa\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBa+\fR
.sp
Match a sequence of one or more
\fBa\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBa?\fR
.sp
Match zero or one
\fBa\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBab|cd\fR
.sp
Match
\fBab\fR
or
\fBcd\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBa{5}\fR
.sp
Match five instances of
\fBa\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBa{2,5}\fR
.sp
Match from two to five instances of
\fBa\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB(abc)+\fR
.sp
Match one or more repetitions of
\fBabc\fR\&.
.RE
.PP
This is but a brief set of examples of regular expressions\&. The full syntax is described in the
\m[blue]\fBMySQL manual\fR\m[]\&\s-2\u[1]\d\s+2, but can often be found in
\fIregex(7)\fR\&.
OPTIONS
.PP
\fBmysqlmetagrep\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
.\}
\-\-body, \-b
.sp
Search the body of stored programs (procedures, functions, triggers, and events)\&. The default is to match only the name\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-database=<pattern>
.sp
Look only in databases matching this pattern\&.
.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 output display format\&. 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
.\}
\-\-object\-types=<types>, \-\-search\-objects=<types>
.sp
Search only the object types named in
\fItypes\fR, which is a comma\-separated list of one or more of the values
\fBprocedure\fR,
\fBfunction\fR,
\fBevent\fR,
\fBtrigger\fR,
\fBtable\fR, and
\fBdatabase\fR\&.
.sp
The default is to search in objects of all types\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-pattern=<pattern>, \-e=<pattern>
.sp
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
\fB\-\-pattern\fR
option is given, the first nonoption argument is treated as a connection specifier, not as a pattern\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-regexp, \-\-basic\-regexp, \-G
.sp
Perform pattern matches using the
\fBREGEXP\fR
operator\&. The default is to use
\fBLIKE\fR
for matching\&. This affects the
\fB\-\-database\fR
and
\fB\-\-pattern\fR
options\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-server=<source>
.sp
Connection information for a server to search in the format: <\fIuser\fR>[:<\fIpasswd\fR>]@<\fIhost\fR>[:<\fIport\fR>][:<\fIsocket\fR>] or <\fIlogin\-path\fR>[:<\fIport\fR>][:<\fIsocket\fR>]\&. Use this option multiple times to search multiple servers\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-sql, \-\-print\-sql, \-p
.sp
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\&.
.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
NOTES
.PP
For the
\fB\-\-format\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\-\-format=g\fR
specifies the grid format\&. 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)\&.
EXAMPLES
.PP
Find all objects with a name that matches the pattern
\*(Aqt_\*(Aq
(the letter t followed by any single character):
.sp
.if n \{\
.RS 4
.\}
.nf
$ 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 |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
.fi
.if n \{\
.RE
.\}
.PP
To find all object that contain
\*(Aqt2\*(Aq
in the name or the body (for routines, triggers, and events):
.sp
.if n \{\
.RS 4
.\}
.nf
$ 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 |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
.fi
.if n \{\
.RE
.\}
.PP
In the preceding output, the trigger name does not match the pattern, but is displayed because its body does\&.
.PP
This is the same as the previous example, but using the
\fBREGEXP\fR
operator\&. Note that in the pattern it is not necessary to add wildcards before or after t2:
.sp
.if n \{\
.RS 4
.\}
.nf
$ 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 |
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
.fi
.if n \{\
.RE
.\}
.SH "COPYRIGHT"
.br
.SH "NOTES"
.IP " 1." 4
MySQL manual
.RS 4
\%http://dev.mysql.com/doc/mysql/en/regexp.html
.RE
.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/).
|