SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having problems setting a primary key in a MySQL text field...

    I'm trying to use phpMyAdmin to do it and I get this:


    Error
    SQL-query:

    ALTER TABLE Author_Info DROP PRIMARY KEY, ADD PRIMARY KEY(First_Name)
    MySQL said: BLOB column 'First_Name' used in key specification without a key length


    I'm also not entirely sure what they mean by key length and why its a blob column when its a text column. I try to specify a length and that doesn't work either so I must be doing it wrong. Any help?
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am pretty sure that a text field is the same as a blob field except for it is case-insensitive. So basically when searching a blob field your search would be case-sensitive and when searchinga text field it wouldn't. Also I think a text field is way overkill for a first_name field why not varchar(100) there probably aren't too many people with first_name's over 100 characters.
    Also when making indexes on blob or text fields you must use only a portion of the field in your key like

    PRIMARY KEY(first_name(10))

    I still would go with a varchar(100) or a varchar(50) for this job. These you can put in a PRIMARY KEY
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •