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 6166065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:16:31+00:00 2026-05-23T22:16:31+00:00

For a table I’m creating that include IP ranges, I need to store two

  • 0

For a table I’m creating that include IP ranges, I need to store two 128-bit (16-byte) int values in a MySQL record. Since MySQL only supports up to 8-byte ints, I’ve found that I need to use a binary column (tinyblob), which is all well and good.

CREATE TABLE `ip_ranges` (
    `ip_start` tinyblob NOT NULL,
    `ip_end` tinyblob NOT NULL,
    ...
    UNIQUE KEY `index_ip_ranges_on_ip_start_and_ip_end` (`ip_start`(16),`ip_end`(16))
);

I’m running into trouble with my unique index on these two columns. As far as I understand, IPv6’s integer representation is 128 bits (16 bytes). As such, I set the unique index for the ip_start and ip_end columns in the unique key to be 16 bytes. Unfortunately, I end up getting duplicate key errors when populating with real IPv6 data:

  > INSERT INTO `ip_ranges` (`ip_end`, `ip_start`, ...) VALUES ("42540649945883696925221210589465935872", "42540649945883696943667954663175487487", ...);
  Duplicate entry '42540649945883696925221210589465935872-4254064994588369694366795' for key 'index_ip_ranges_on_ip_start_and_ip_end'

The key value displayed on the “duplicate entry” line above makes it look like a part of the ip_end value is being lopped off. It’s missing the last 13 digits: “4663175487487”. This makes me think I’m wrong about the “16” that I’m providing to the unique key length representing bytes.

What’s going on here, and how can I fix it?

  • 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-23T22:16:31+00:00Added an answer on May 23, 2026 at 10:16 pm

    No. No TINYBLOB. Use VARBINARY.
    Even then, each digit will be store as one byte, so your key will need to be 39B long.

    Alternatively you could use DECIMAL(39)

    Or wait until MySQL 5.6 with native IPv6 support ;P

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A table exists that someone else loaded. I need to query against the table,
The table doesn't have a last updated field and I need to know when
create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int
Table layout: CREATE TABLE t_order (id INT, custId INT, order DATE) I'm looking for
Table: CREATE TABLE Instrument ( Id INT IDENTITY , Name VARCHAR(50) , Tenor VARCHAR(10)
Table UserData (UserID, Sales, Credits) I need to return the SUM of sales, sum
Table items keeps track of the different types of items that can be stocked.
Table A has column X, which is an int made up of the concatenation
Table view cell management has driving me crazy from past two days. Please check
I have a script that appends some rows to a table. One of the

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.