• MySQL中表的基本操作2


     mysql> insert into teacher
         -> values (202, 'robot', 'ZhuHai', '2013-04-24');
     Query OK, 1 row affected (0.00 sec)
     
     mysql> insert into teacher
         -> values (203, 'Jack', 'ZhuHai', '2013-04-24');
     Query OK, 1 row affected (0.00 sec)
     
     mysql> insert into teacher
         -> values (204, 'Ann', 'ZhuHai', '2013-04-24');
     Query OK, 1 row affected (0.01 sec)
     
     mysql> insert into teacher
         -> values (205, 'Rose', 'ZhuHai', '2013-04-24');
     Query OK, 1 row affected (0.01 sec)

    (1)统计有多少条记录

     mysql> select count(*) from teacher;
     +----------+
     | count(*) |
     +----------+
     |        4 |
     +----------+
     row in set (0.01 sec)
     
     mysql> select * from teacher;
     +-----+-------+---------+------------+
     | Id  | name  | address | year       |
     +-----+-------+---------+------------+
     | 202 | robot | ZhuHai  | 2013-04-24 |
     | 203 | Jack  | ZhuHai  | 2013-04-24 |
     | 204 | Ann   | ZhuHai  | 2013-04-24 |
     | 205 | Rose  | ZhuHai  | 2013-04-24 |
     +-----+-------+---------+------------+
     rows in set (0.00 sec)

    (2)投影操作,选择需要查看的信息

     mysql> select Id, year from teacher;
     +-----+------------+
     | Id  | year       |
     +-----+------------+
     | 202 | 2013-04-24 |
     | 203 | 2013-04-24 |
     | 204 | 2013-04-24 |
     | 205 | 2013-04-24 |
     +-----+------------+
     rows in set (0.00 sec)
    
     mysql> select Id, name from teacher;
     +-----+-------+
     | Id  | name  |
     +-----+-------+
     | 202 | robot |
     | 203 | Jack  |
     | 204 | Ann   |
     | 205 | Rose  |
     +-----+-------+
     rows in set (0.00 sec)

    (3)预览功能,显示字段中一部分的信息

     mysql> select Id, left(address, 3) from teacher;
     +-----+------------------+
     | Id  | left(address, 3) |
     +-----+------------------+
     | 202 | Zhu              |
     | 203 | Zhu              |
     | 204 | Zhu              |
     | 205 | Zhu              |
     +-----+------------------+
     rows in set (0.00 sec)
     
     mysql>
  • 相关阅读:
    【阅读SpringMVC源码】手把手带你debug验证SpringMVC执行流程
    ❀ Spring5学习大总结
    在 Linux 上有哪些运行程序的方式?
    C语言使用宏输出调试信息实战
    vector、map 判断某元素是否存在、查找指定元素
    C语言宏定义中#、##、#@符号的使用
    语言宏的定义和宏的使用方法(#define)
    C宏定义的简单总结
    C语言宏#define中#,##,#@和\的用法
    开源项目
  • 原文地址:https://www.cnblogs.com/Robotke1/p/3041424.html
Copyright © 2020-2023  润新知