MySQL的查询方法

来源:互联网 发布:锦尚中国的源码怎么样 编辑:程序博客网 时间:2024/05/17 18:24

查询表格中的所有方法:

select table_name from information_schema.tables where table_schema='当前数据库'

查询版本的几种方法:
1:在终端下:mysql -V。 以下是代码片段:

  [shengting@login ~]$ mysql -V
  mysql Ver 14.7 Distrib 4.1.10a, for redhat-linux-gnu (i686)

2:在mysql中:mysql> status;

3:在help里面查找
  以下是代码片段:
  [shengting@login ~]$ mysql --help | grep Distrib
  mysql Ver 14.7 Distrib 4.1.10a, for redhat-linux-gnu (i686)

4:使用mysql的函数
  以下是代码片段:
  mysql> select version();
  +-------------+
  | version()   |
  +-------------+
  | 3.23.56-log |
  +-------------+
  1 row in set (0.00 sec)

查询系统时间的方法

1、select current_date;

MySQL> select current_date as Systemtime;
+------------+
| Systemtime |
+------------+
| 2009-07-29 |
+------------+

2、select now()

mysql> select now() as Systemtime;
+---------------------+
| Systemtime          |
+---------------------+
| 2009-07-29 19:06:07 |
+---------------------+

3、select sysdate()

mysql> select sysdate() as Systemtime;
+---------------------+
| Systemtime          |
+---------------------+
| 2009-07-29 19:06:45 |
+---------------------+




0 0
原创粉丝点击