Entering query

来源:互联网 发布:python参考手册 第5版 编辑:程序博客网 时间:2024/05/21 03:28

This section describes the basic principles of entering commands, using several queries you can try out to familiarize yourself with howmysql works.

mysql> SELECT VERSION(), CURRENT_DATE;+------------+--------------+| VERSION()  | CURRENT_DATE |+------------+--------------+| 5.6.21-log | 2014-10-14   |+------------+--------------+row in set (0.05 sec)mysql>

Here is another query. It demonstrates that you can usemysql as a simple calculator:

mysql> SELECT SIN(PI()/4), (3+2)*5;+--------------------+---------+| SIN(PI()/4)        | (3+2)*5 |+--------------------+---------+| 0.7071067811865475 |      25 |+--------------------+---------+

The queries shown thus far have been relatively short, single-line statements. You can even entermultiple statements on a single line. Just end each one with a semicolon:

mysql> SELECT VERSION(); SELECT NOW();+------------+| VERSION()  |+------------+| 5.6.21-log |+------------+row in set (0.30 sec)+---------------------+| NOW()               |+---------------------+| 2014-10-16 14:27:13 |+---------------------+row in set (0.19 sec)mysql>

A command need not be given all on a single line, so lengthy commands that require several lines are not a problem.mysql determines where your statement ends by looking forthe terminating semicolon, not by looking for the end of the input line. (In other words,mysql accepts free-format input: it collects input lines but does not execute themuntil it sees the semicolon.)

Here is a simple multiple-line statement:

<span style="font-family:FangSong_GB2312;font-size:14px;">mysql> SELECT    -> USER()    -> ,    -> CURRENT_DATE;+----------------+--------------+| USER()         | CURRENT_DATE |+----------------+--------------+| root@localhost | 2014-10-16   |+----------------+--------------+</span>
If you decide you do not want to execute a command that you are in the process of entering, cancel it by typing\c:

mysql> SELECT    -> USER()    -> \C          ;;小写的才对ERROR: Usage: \C charset_name | charset charset_name    -> \cmysql>





0 0
原创粉丝点击