0
点赞
收藏
分享

微信扫一扫

最近工作中遇到的4个问题(2019-6-10)


最近工作中遇到的4个问题(2019-6-10)
1. 不同环境用不同的域名,来回切host很不方便
线上直接 account.com,不需要配置host
//本地
127.0.0.1 account-dev.com
//测试
192.168.16.35 account-test.com
//线上
192.168.2.7 account-pre.com

2.select * from user \G;
在sql语句后面加\G表示将查询结果按列打印。默认情况下,mysql的查询结果是横向输出的,第一行是列头,后面是记录集,比如:
id|name|depid
1|Tonny|1
这样的话,假如字段比如多,出来的结果就非常乱,非常不适合人类阅读,而加上\G参数之后,表结构就变成纵向输出,即每条记录都会用
参考资料:https://zhidao.baidu.com/question/1947974646033420348.html

3.date 时区
show variables like "%time_zone%";
数据库时间,看的是“2019-05-01 11:11:11”,数据库查询出来可能是“2019-05-02”。
时区问题导致的。
time_zone  SYSTEM
system_time_zone CST


4、注意mysql的not in查询值中存在null值时返回的查询结果会一直为空
select * from user where  comp_id not in(1,2);
如果
某条记录comp_id为NULL,虽然不在not in里,但是查询不出来。
把comp_id改为""就可以。
更新已有null数据为""
update user set comp_id ="" where comp_id is null;

更改默认值为""
alter table user alter column comp_id set default "";


举报

相关推荐

0 条评论