设为首页 加入收藏

TOP

mysql查询类型转换
2014-11-24 07:36:11 来源: 作者: 【 】 浏览:0
Tags:mysql 查询 类型 转换
mysql查询类型转换
在mysql查询时最好不要发生类型转换,如把varchar转换成int
mysql> explain select * from user where name=1\G

//如果你确定name字段是整型就不要把它转化成字符串,不加单引号
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: user
         type: ALL
possible_keys: index_name_password
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 99727
        Extra: Using where
1 row in set (0.02 sec)


mysql> explain select * from user where name='1'\G

//如果你确定name字段是字符串就不要把它转化成整型,加单引号
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: user
         type: ref
possible_keys: index_name_password
          key: index_name_password
      key_len: 111
          ref: const
         rows: 1
        Extra: Using where
1 row in set (0.00 sec)


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇postgresql建立删除分区表 下一篇mysql主从问题处理记录

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·在 Redis 中如何查看 (2025-12-26 03:19:03)
·Redis在实际应用中, (2025-12-26 03:19:01)
·Redis配置中`require (2025-12-26 03:18:58)
·Asus Armoury Crate (2025-12-26 02:52:33)
·WindowsFX (LinuxFX) (2025-12-26 02:52:30)