• mysql 5.1按月建立分区表出现问题


    1, info_time div 100,timestamp为什么要这么运算?适用于datetime吗?
    同样适用,当日期型与算术运行符一起时,mysql会将日期型数据隐式转换为数字。 20090611

    2,我在建立表的时候将id设置成为主键,结果出现错误:
    MySQL主键的限制,每一个分区表中的公式中的列,必须在主键/unique key 中包括

    下面这段摘自MySQL的官方文档,斜体是文档本身就标识为斜体的。可惜在中文文档中我们没找到这 一句。
    18.5.1. Partitioning Keys, Primary Keys, and Unique Keys
    This section discusses the relationship of partitioning keys with primary keys and unique keys. The rule governing this relationship can be expressed as follows: All columns used in the partitioning expression for a partitioned table must be part of every unique key that the table may have.

    In other words, every unique key on the table must use every column in the table's partitioning expression. (This also includes the table's primary key, since it is by definition a unique key. This particular case is discussed later in this section.) For example, each of the following table creation statements is invalid:

    mysql> create table tx (
        ->     id int not null ,
        ->     info_time date,
        ->     primary key(id,info_time)
        -> )
        -> PARTITION BY RANGE(info_time div 100)
        -> (
        ->     PARTITION p_2008_11 VALUES LESS THAN (200812),
        ->     PARTITION p_2008_12 VALUES LESS THAN (200901),
        ->     PARTITION p_2009_01 VALUES LESS THAN (200902),
        ->     PARTITION p_2009_02 VALUES LESS THAN (200903),
        ->     PARTITION p_2009_03 VALUES LESS THAN (200904),
        ->     PARTITION p_2009_04 VALUES LESS THAN (200905),
        ->     PARTITION p_catch_all VALUES LESS THAN MAXVALUE
        -> );
    Query OK, 0 rows affected (0.17 sec)

    mysql>

    为了确保主键的效率。否则同一主键区的东西一个在A分区,一个在B分区,显然会比较麻烦。

  • 相关阅读:
    weblogic 的应用 常见问题处理 db2 链接不上(转载)
    WebLogic简单的备份和恢复
    linux 切换用户之后变成-bash-x.x$的解决方法
    weblogic迁移随手记
    生产环境下Centos 6.5优化配置 (装载)
    查看db2表空间使用率
    Linux 之 rsyslog 系统日志转发(转载)
    windows下定时利用bat脚本实现ftp上传和下载
    rsyslog同步history日志(转载)
    linux比较指令comm、diff、grep -Ff
  • 原文地址:https://www.cnblogs.com/youlechang123/p/3125541.html
Copyright © 2020-2023  润新知