資料庫對錶的操作練習。

2021-10-02 01:12:46 字數 3171 閱讀 1151

檢視崗位是teacher的員工姓名、年齡

檢視崗位是teacher且年齡大於30歲的員工姓名、年齡

檢視崗位是teacher且薪資在9000-1000範圍內的員工姓名、年齡、薪資

檢視崗位描述不為null的員工資訊

檢視崗位是teacher且薪資是10000或9000或30000的員工姓名、年齡、薪資

檢視崗位是teacher且薪資不是10000或9000或30000的員工姓名、年齡、薪資

檢視崗位是teacher且名字是jin開頭的員工姓名、年薪

1.#檢視崗位是teacher的員工姓名、年齡

mysql> select name,age from employee where post = 'teacher';

+------------+-----+

| name | age |

+------------+-----+

| alex | 78 |

| wupeiqi | 81 |

| yuanhao | 73 |

| liwenzhou | 28 |

| jingliyang | 18 |

| jinxin | 18 |

| 成龍 | 48 |

+------------+-----+

2.#檢視崗位是teacher且年齡大於30歲的員工姓名、年齡

mysql> select name,age from employee where post = 'teacher' and age > 30;

+---------+-----+

| name | age |

+---------+-----+

| alex | 78 |

| wupeiqi | 81 |

| yuanhao | 73 |

| 成龍 | 48 |

+---------+-----+

3.#檢視崗位是teacher且薪資在9000-1000範圍內的員工姓名、年齡、薪資

mysql> select name,age,salary from employee where post = 'teacher'and salary > 1000 and salary<9000;

+-----------+-----+---------+

| name | age | salary |

+-----------+-----+---------+

| wupeiqi | 81 | 8300.00 |

| yuanhao | 73 | 3500.00 |

| liwenzhou | 28 | 2100.00 |

+-----------+-----+---------+

4.# 檢視崗位描述不為null的員工資訊

mysql> select * from employee where post_comment is not null;

empty set (0.00 sec)

5.#檢視崗位是teacher且薪資是10000或9000或30000的員工姓名、年齡、薪資

mysql> select name,age,salary from employee where salary in (10000,9000,30000);

+------------+-----+----------+

| name | age | salary |

+------------+-----+----------+

| jingliyang | 18 | 9000.00 |

| jinxin | 18 | 30000.00 |

| 成龍 | 48 | 10000.00 |

+------------+-----+----------+

6.#檢視崗位是teacher且薪資不是10000或9000或30000的員工姓名、年齡、薪資

mysql> select name,age,salary from employee where salary not in(10000,9000,30000);

+-----------+-----+------------+

| name | age | salary |

+-----------+-----+------------+

| egon | 18 | 7300.33 |

| alex | 78 | 1000000.31 |

| wupeiqi | 81 | 8300.00 |

| yuanhao | 73 | 3500.00 |

| liwenzhou | 28 | 2100.00 |

| 歪歪 | 48 | 3000.13 |

| 丫丫 | 38 | 2000.35 |

| 丁丁 | 18 | 1000.37 |

| 星星 | 18 | 3000.29 |

| 格格 | 28 | 4000.33 |

| 張野 | 28 | 10000.13 |

| 程咬金 | 18 | 20000.00 |

| 程咬銀 | 18 | 19000.00 |

| 程咬銅 | 18 | 18000.00 |

| 程咬鐵 | 18 | 17000.00 |

+-----------+-----+------------+

7.# 檢視崗位是teacher且名字是jin開頭的員工姓名、年薪

mysql> select name,salary from employee where name like 'jin%';

+------------+----------+

| name | salary |

+------------+----------+

| jingliyang | 9000.00 |

| jinxin | 30000.00 |

+------------+----------+

資料庫中對錶的基礎操作

1.對於初學者先點一下,注釋不是 而是 2.使用者的資料實際上是存放在資料庫的表中,所以當我們要向資料庫中存放資料時,必須先建立表。3.建立語法 create table 模式名 欄位2 型別 約束條件 欄位2 型別 約束條件 tablespace 命名空間 4.新增一條資料 eg insert i...

Oracle資料庫對表字段的操作命令

在二次開發乙個工程時,經常會遇到對庫表的字段的操作,以下是部分常用到的命令 新增表 tdm weld 字段 例子1 alter table tdm weld add is aut number 1 default 0,is embalmed number 1 default 0 例子二 alter ...

Mysql資料庫對錶的修改

mysql資料庫中對資料庫表的修改 1.語法 alter table 舊表名 rename to 新表明 例 使用alter table 命令將 studentinfo 表修改為 student alter table studentinfo rename to student 2.修改資料型別 修...