SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Iím trying to create a members table in MySQL using the Email address of the member as a primary key. So, with my limited knowledge of SQL, I type in the following command at the TelNet prompt:

    CREATE TABLE Member (
    Email TEXT NOT NULL PRIMARY KEY,
    Password TEXT,
    FirstName TEXT,
    LastName TEXT
    );

    Iím then, however, presented with the following error message:

    ERROR 1073: BLOB column ĎEmailí canít be used in key specification

    Why am I getting this error, and how do I create a table with the Email address as the primary key?

    Thanks in advance !
    Sincerely,

    Eirik Johansen
    Netmaking AS

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Without knowing much about this - it doesn't suprise me if MySQL doesn't allow you to use a text field as a primary key, because the primary key is automatically indexed it would be a very ineffiecent index (given that a text field is <scientific term> bloody big </scientific term>).

    Use a varchar type instead. How many characters would be enough for an email? - 100?

    Email VARCHAR(100) NOT NULL PRIMARY KEY

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes Sid is right on.

    You shouldn't use a text field anyways since its inefficient. Use varchar for things like Name, Email, etc. text should only be used for storing articles, or books, or other long things.
    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

  4. #4
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help, guys! I really appreciate it!
    Sincerely,

    Eirik Johansen
    Netmaking AS


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
  •