zoukankan      html  css  js  c++  java
  • 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分区,显然会比较麻烦。

  • 相关阅读:
    攻防世界新手RE 6.getit
    攻防世界新手RE 5.logmein
    攻防世界新手RE 4.simple-unpack
    攻防世界新手RE 3.open-source
    攻防世界新手RE 2.Hello, CTF
    {DARK CTF }Misc/Minetest1 2 3
    {DARK CTF } forensics /Wolfie's Contact
    {DARK CTF } OSINT/Dark Social Web
    2021 1 13 js笔记5 end,JSON学习笔记
    2021 1 12 js笔记4
  • 原文地址:https://www.cnblogs.com/youlechang123/p/3125541.html
Copyright © 2011-2022 走看看