1. 查看表内行数 ```shell mysql> select count() from mysql.user; +—————+ | count() | +—————+ | 9 | +—————+ 1 row in set (0.00 sec)

    mysql>

    1. 1. 查看表内行数
    2. ```shell
    3. mysql> select * from mysql.db;
    4. +---------------+---------+-------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
    5. | Host | Db | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv | Event_priv | Trigger_priv |
    6. +---------------+---------+-------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
    7. | % | test | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y | Y | Y | N | N | Y | Y |
    8. | % | test\_% | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y | Y | Y | N | N | Y | Y |
    9. | 192.168.133.1 | db1 | user2 | Y | Y | Y | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N |
    10. | % | db1 | user3 | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
    11. +---------------+---------+-------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
    12. 4 rows in set (0.00 sec)
    1. 查看db表内含有db字段的内容
      ```shell mysql> select db from mysql.db; +————-+ | db | +————-+ | db1 | | test | | test_% | | db1 | +————-+ 4 rows in set (0.00 sec)
    1. 3. 查看db表内含有db字段的内容
    2. ```shell
    3. mysql> select db,user from mysql.db;
    4. +---------+-------+
    5. | db | user |
    6. +---------+-------+
    7. | db1 | user3 |
    8. | test | |
    9. | test\_% | |
    10. | db1 | user2 |
    11. +---------+-------+
    12. 4 rows in set (0.00 sec)
    13. mysql>
    1. 查询host为192.168的内容 ```shell mysql> select from mysql.db where host like ‘192.168.%’\G; * 1. row *
      1. Host: 192.168.133.1
      2. Db: db1
      3. User: user2
      4. Select_priv: Y
      5. Insert_priv: Y
      6. Update_priv: Y
      7. Delete_priv: N
      8. Create_priv: N
      9. Drop_priv: N
      10. Grant_priv: N
      References_priv: N
      1. Index_priv: N
      2. Alter_priv: N
      Create_tmp_table_priv: N Lock_tables_priv: N Create_view_priv: N
      1. Show_view_priv: N
      Create_routine_priv: N Alter_routine_priv: N
      1. Execute_priv: N
      2. Event_priv: N
      3. Trigger_priv: N
      1 row in set (0.00 sec)

    ERROR: No query specified

    1. 6. db1.t1中插入内容
    2. ```shell
    3. mysql> insert into db1.t1 values(1,'abc');
    4. Query OK, 1 row affected (0.01 sec)
    5. mysql> select * from db1.t1;
    6. +------+------+
    7. | id | name |
    8. +------+------+
    9. | 1 | abc |
    10. +------+------+
    11. 1 row in set (0.00 sec)
    1. 把id=1的字段内容更新成aaa ```shell mysql> update db1.t1 set name=’aaa’ where id = 1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0

    mysql> select * from db1.t1; +———+———+ | id | name | +———+———+ | 1 | aaa | +———+———+ 1 row in set (0.00 sec)

    1. 8. 清空db1.t1表内的内容
    2. ```shell
    3. mysql> truncate table db1.t1;
    4. Query OK, 0 rows affected (0.00 sec)
    5. mysql> select * from db1.t1;
    6. Empty set (0.00 sec)
    1. 删除db1.t1数据库 ```shell mysql> mysql> drop database db1; Query OK, 1 row affected (0.00 sec)

    mysql> mysql> show databases; +——————————+ | Database | +——————————+ | information_schema | | mysql | | performance_schema | | test | | ytl | +——————————+ 5 rows in set (0.00 sec)

    mysql>

    ```