mysql命令 a Mysql命令大全

2021-10-17 19:56:47 字數 1501 閱讀 5693

命令:mysql> select database();

mysql中select命令類似於其他程式語言裡的print或者write,你可以用它來顯示乙個字串、數字、數學表示式的結果等等。如何使用mysql中select命令的特殊功能?

1.顯示mysql的版本

mysql> select version();

| version()             |

| 6.0.4-alpha-community |

1 row in set (0.02 sec)

2. 顯示當前時間

mysql> select now();

| now()               |

| 2009-09-15 22:35:32 |

1 row in set (0.04 sec)

3. 顯示年月日

select dayofmonth(current_date);

| dayofmonth(current_date) |

|                       15 |

1 row in set (0.01 sec)

select month(current_date);

| month(current_date) |

|                   9 |

1 row in set (0.00 sec)

select year(current_date);

| year(current_date) |

|               2009 |

1 row in set (0.00 sec)

4. 顯示字串

mysql> select "welecome to my blog!";

| welecome to my blog! |

| welecome to my blog! |

1 row in set (0.00 sec)

5. 當計算器用

select ((4 * 4) / 10 ) + 25;

| ((4 * 4) / 10 ) + 25 |

|                26.60 |

1 row in set (0.00 sec)

6. 串接字串

select concat(f_name, " ", l_name)

as name

from employee_data

where title = 'marketing executive';

| name          |

| monica sehgal |

| hal simlai    |

| joseph irvine |

3 rows in set (0.00 sec)

注意:這裡用到concat()函式,用來把字串串接起來。另外,我們還用到以前學到的as給結果列'concat(f_name, " ", l_name)'起了個假名。

mysql 命令 mysql 命令

刪除 delete from user 刪除user表中所有記錄 不帶星號 顯示記錄數 select count 1 from user 不用count 效率低 可以替換成欄位名 select count tigan from tiku mysql create database db name 建...

mysql命令 Mysql命令大全

7.1 乙個建庫和建表的例項1 drop database if exists school 如果存在school則刪除 create database school 建立庫school use school 開啟庫school create table teacher 建立表teacher id ...

mysql命令測試 mysql命令

7.1 乙個建庫和建表的例項1 drop database if exists school 如果存在school則刪除 create database school 建立庫school use school 開啟庫school create table teacher 建立表teacher id ...