Spec-Zone .ru
спецификации, руководства, описания, API

4.2.3.1. Using Options on the Command Line

Program options specified on the command line follow these rules:

Option values that contain spaces must be quoted when given on the command line. For example, the --execute (or -e) option can be used with mysql to pass SQL statements to the server. When this option is used, mysql executes the statements in the option value and exits. The statements must be enclosed by quotation marks. For example, you can use the following command to obtain a list of user accounts:

mysql> mysql -u root -p --execute="SELECT User, Host
        FROM mysql.user"Enter password: ******+------+-----------+| User | Host      |+------+-----------+|      | gigan     || root | gigan     ||      | localhost || jon  | localhost || root | localhost |+------+-----------+shell>

Note that the long form (--execute) is followed by an equals sign (=).

If you wish to use quoted values within a statement, you will either need to escape the inner quotation marks, or use a different type of quotation marks within the statement from those used to quote the statement itself. The capabilities of your command processor dictate your choices for whether you can use single or double quotation marks and the syntax for escaping quote characters. For example, if your command processor supports quoting with single or double quotation marks, you can use double quotation marks around the statement, and single quotation marks for any quoted values within the statement.

Multiple SQL statements may be passed in the option value on the command line, separated by semicolons:

shell> mysql -u root -p -e "SELECT VERSION();SELECT
        NOW()"Enter password: ******+-----------------+| VERSION()       |+-----------------+| 5.1.5-alpha-log |+-----------------++---------------------+| NOW()               |+---------------------+| 2006-01-05 21:19:04 |+---------------------+