Editing Complex Commands with a Text Editor

Although the mysql environment is convenient for entering small queries, it can be very tedious to enter long queries. If you find that a query is getting overly long or needs serious editing, type \e at the end of the query and press Enter. This feature is not available on Windows systems.

The editor referred to by the $EDITOR environment variable opens, with the query to be edited already in place. Edit the query as you would any other text, save the file (which will have an odd-looking name), and exit the editor.

The query is loaded into mysql, but is not executed. To execute the query, type ; (or \G to display the query results in a list instead of in a table), and press Enter.

See your shell documents for information on how to set the $EDITOR environment variable.


The default editor might be vi or vim. Although these are both fine editors, they can be very challenging to use for those unfamiliar with them. If you want to bravely forge ahead, type :help<enter> to get help on using the editor. If you want to sensibly retreat, type :q!<enter>.

MySQL Phrasebook. Essential Code and Commands
MySQL Phrasebook
ISBN: 0672328399
EAN: 2147483647
Year: 2003
Pages: 130

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net