Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7697035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:55:05+00:00 2026-05-31T21:55:05+00:00

The following CREATE TABLE statement to partition a table works as expected, without error.

  • 0

The following CREATE TABLE statement to partition a table works as expected, without error.

CREATE TABLE `ox_data_archive_20120108` (
    `id` bigint(20) unsigned NOT NULL,
    `creativeid` int unsigned NOT NULL,
    `zoneid` int unsigned NOT NULL,
    `datetime` datetime NOT NULL
) PARTITION BY LIST(to_days(datetime )) (
      PARTITION `1Jan10` VALUES IN (to_days('2010-01-01') ),
      PARTITION `2Jan10` VALUES IN (to_days('2010-01-02') ),
      PARTITION `3Jan10` VALUES IN (to_days('2010-01-03') )
  );

What I need to do is to create subpartitions based on date + zoneid. I tried the following:

CREATE TABLE mypart (
    `id` bigint(20) unsigned NOT NULL,
    `creativeid` int unsigned NOT NULL,
    `zoneid` int unsigned NOT NULL,
    `datetime` datetime NOT NULL
) PARTITION BY LIST(to_days(datetime )) 
  SUBPARTITION BY KEY(zoneid) (
      PARTITION `1Jan10` VALUES IN (to_days('2010-01-01') )
        (Subpartition s1, Subpartition s2),
      PARTITION `2Jan10` VALUES IN (to_days('2010-01-02') ) 
        (Subpartition s3, Subpartition s4),
      PARTITION `3Jan10` VALUES IN (to_days('2010-01-03') )
        (Subpartition s5, Subpartition s6)
  );

Inserting into this table:

INSERT INTO mypart VALUES (1, 2, 3, '2012-01-31 04:10:03');

results in the following error:

ERROR 1526 (HY000): Table has no partition for value 734898

My query expects to use the zoneid subpartition based on dates. Is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:55:06+00:00Added an answer on May 31, 2026 at 9:55 pm

    Contrary to your assertion that the first table works without error, inserting the sample data into it:

    INSERT INTO `ox_data_archive_20120108` VALUES (1, 2, 3, '2012-01-31 04:10:03');
    

    results in the same error as for the second table. The value given in the error (734898) happens to be the value for to_days('2012-01-31'). You get this error because you only have partitions for January 1st through 3rd, 2010. Both the day-of-month and the year for the sample data are outside the defined partitions. Instead of TO_DAYS (which returns the number of days from year 0 to the given date), you probably want DAYOFMONTH. Since each partition is contiguous, a RANGE partition seems more appropriate than a LIST.

    Off topic, you only need to specify separate subpartition definitions when you want to set options for the subpartitions. Since you’re not doing that, a SUBPARTITIONS 2 clause will do the same thing as your statement, but is simpler.

    CREATE TABLE mypart (
        `id` bigint(20) unsigned NOT NULL,
        `creativeid` int unsigned NOT NULL,
        `zoneid` int unsigned NOT NULL,
        `datetime` datetime NOT NULL
    ) PARTITION BY RANGE(DAYOFMONTH(`datetime`)) 
      SUBPARTITION BY KEY(zoneid) 
      SUBPARTITIONS 2 (
          PARTITION `01` VALUES LESS THAN 2, -- Note: 0 is valid day-of-month
          PARTITION `02` VALUES LESS THAN 3,
          PARTITION `03` VALUES LESS THAN 4,
          ...
      );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following SQL: CREATE TABLE USER1 ( pkUSER1_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
I have the following tables CREATE TABLE `files` ( `fileid` int(11) NOT NULL AUTO_INCREMENT,
I have created an sqlite table using the following statement: CREATE TABLE IF NOT
I have the following sql create statement mysql> CREATE TABLE IF NOT EXISTS `erp`.`je_menus`
Say i have the following table: create table T ( ID int not null
If I have the following SQL query CREATE TABLE #t1 (a INT NOT NULL
I am trying the following SQL statement: create table sample ( id int not
With the following tables CREATE TABLE `Play` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id`
I have the following table: CREATE TABLE [dbo].[PartsWork]( [parts_work_id] [int] IDENTITY(1,1) NOT NULL, [experiment_id]
I cannot find the syntax error in the following statement: CREATE TABLE dbo.statslogsummary as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.