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

  • Home
  • SEARCH
  • 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 6052245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:54:26+00:00 2026-05-23T07:54:26+00:00

This is very straight problem but I haven’t figured out any solution yet. Scenario

  • 0

This is very straight problem but I haven’t figured out any solution yet.
Scenario is I have 2 table in my DB. Source of 2nd table is dependent on 1st table’s SOURCE_URL(can be more than 255 char so I have used TEXT).

create table SOURCES (
        SOURCES_PK int not null AUTO_INCREMENT primary key,
        SOURCE_URL text not null unique,
        DESCRIPTION varchar(255)
);

create table ASSERTIONGROUP (
        ASSERTION_PK int AUTO_INCREMENT primary key,
        LABEL varchar(255),
        SOURCE text not null,
        foreign key (SOURCE) references SOURCES(SOURCE_URL)
);

I am getting this error-

BLOB/TEXT column ‘SOURCE’ used in key specification without a key length

I have seen discussion in this post – MySQL error: key specification without a key length.
But can’t figure out any solution.
I can remove unique from 1st table but then I can’t assign foreign key constraint.

I know that TEXT field can’t be unique so looking for an alternative.

  • 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-23T07:54:27+00:00Added an answer on May 23, 2026 at 7:54 am

    In order to match against a long varchar or blob column you’ll need to specify the index length:

    create table SOURCES (
      SOURCES_PK int not null AUTO_INCREMENT primary key,                    
      SOURCE_URL text not null unique,                    
      DESCRIPTION varchar(255),
      INDEX source_url (source_url(100)) );
    //  Key length ----------------^^^ 
    

    For MyISAM

    The maximum key length is 1000 bytes. This can also be changed by changing the source and recompiling. For the case of a key longer than 250 bytes, a larger key block size than the default of 1024 bytes is used.

    For InnODB

    Index key prefixes can be up to 767 bytes. See Section 12.1.8, “CREATE INDEX Syntax”.

    See: http://dev.mysql.com/doc/refman/5.5/en/create-table.html

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

Sidebar

Related Questions

I have this very straight forward question regarding Thread and Timer classes in Java
I'm relatively new to the Python world, but this seems very straight forward. Google
This is probably a very straight forward application, but I am new to Objective-C
This seems like it should be straight-forward, but I'm stumped. I have a link
This might be something very straight forward and I really think it should work
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Straight to the point: I have this javascript: for(item=1;item<5;item++) { xmlhttp=new XMLHttpRequest(); xmlhttp.open(GET,'zzz.php', true);
I am sure this is a straight forward application, but not sure what the
Okay I have seen some very similar questions here but none seem to be
I'm sure that this is very straight-forward, however, after scouring the net I can't

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.