zoukankan      html  css  js  c++  java
  • 数据库

    数据库问题汇总

    1.util.Date类型数据插入mysql时数据库时,日期会少13小时

    在连接参数中添加“serverTimezone=Asia/Shanghai”。

    2.定义band字段在 Mybatis中关于OGNL表达式会出现冲突:Malformed OGNL expression: band != null

    表字段为band,band是捆绑的意思,与mybatis的OGNL表达式发生冲突。可能发生冲突的变量集合

    • bor  字符|
    • xor      字符^
    • and      字符&&
    • band    字符&
    • eq       字符==
    • neq     字符!=
    • lt        字符<
    • gt       字符>
    • lte       字符<=
    • gte     字符>=
    • shl     字符 <<
    • shr     字符>>
    • ushr    字符>>>

    3.com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.QRTZ_TRIGGERS' doesn't exist

    问题:数据库中明这张表 qrtz_triggers 还是报这个错

    原因:这个错报的是在数据库test下面没有这个表【QRTZ_TRIGGERS】。其实数据库中有的是【qrtz_triggers】。区别在于一个是大写,一个是小写。默认情况下,mysql是区分大小写的,所以为了避免这种问题,就需要把 mysql 的区分大小写的属性给修改了。

    解决办法:

    用root登录,修改 /etc/my.cnf。在[mysqld]节点下,加入一行: lower_case_table_names=1

    CentOS 7下mysql停止和重启:

    /bin/systemctl stop mysqld.service
    
    /bin/systemctl restart mysqld.service

    4.各数据库表名和字段名长度限制

    5.mysql修改端口号

    登录mysql:

    mysql -u root -p

    查看当前端口:

    show global variables like 'port';

    修改 my.cnf 配置文件的 port 属性:

    port=要修改的端口号

    重启mysql:

    service mysqld restart 

    6.UNION ALL为什么会降低性能

    High Performance MySQL, Second Edition P195
    
    Optimizing UNION
    MySQL always executes UNION queries by creating a temporary table and filling it
    with the UNION results. MySQL can’t apply as many optimizations to UNION queries as
    you might be used to. You might have to help the optimizer by manually “pushing down” 
    WHERE, LIMIT, ORDER BY, and other conditions (i.e., copying them, as appropri-
    ate, from the outer query into each SELECT in the UNION).
    It’s important to always use UNION ALL, unless you need the server to eliminate dupli-
    cate rows. If you omit the ALL keyword, MySQL adds the distinct option to the tem-
    porary table, which uses the full row to determine uniqueness. This is quite
    expensive. Be aware that the ALL keyword doesn’t eliminate the temporary table,
    though. MySQL always places results into a temporary table and then reads them
    out again, even when it’s not really necessary (for example, when the results could be
    returned directly to the client).

    union 会生成临时表,整个过程就相当于是先写再读,所以在某些情况下速度会变慢很多。

    7.mybatis中大于等于小于等于的写法

    大于等于
    <![CDATA[ >= ]]>
    小于等于
    <![CDATA[ <= ]]>
    例如:sql如下:
    create_date_time <![CDATA[ >= ]]> #{startTime} and  create_date_time <![CDATA[ <= ]]> #{endTime}
  • 相关阅读:
    ASP.NET Web开发框架之二 数据输入窗体
    针对HTML5的更新和Unobtrusive Validation
    框架:从MVC到开放API
    使用SSIS创建同步数据库数据任务
    MVC里的Filters
    类型构造器也称为静态构造器,类构造器,或类型初始化器
    铁道部新客票系统设计(二)
    深入浅出SQL Server中的死锁
    你所能用到的数据结构(一)
    python网络编程学习笔记(6):Web客户端访问
  • 原文地址:https://www.cnblogs.com/helios-fz/p/11149607.html
Copyright © 2011-2022 走看看