Primary key error

ERROR 1063 (42000): Incorrect column specifier for column 'ID'

Page 1 of 1

2 Replies - 2110 Views - Last Post: 27 July 2009 - 03:56 PM Rate Topic: -----

#1 Pencil  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 7
  • Joined: 27-July 09

Primary key error

Posted 27 July 2009 - 01:54 PM

When I google it most say that the primary key should be an int or a varchar but i need it to be a bit longer.


ID longblob not null auto_increment PRIMARY KEY



The error:

Primary key error, ERROR 1063 (42000): Incorrect column specifier for column 'ID'

This post has been edited by Pencil: 27 July 2009 - 01:55 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Primary key error

#2 AdaHacker  Icon User is offline

  • Resident Curmudgeon

Reputation: 452
  • View blog
  • Posts: 811
  • Joined: 17-June 08

Re: Primary key error

Posted 27 July 2009 - 02:39 PM

I'm pretty sure you can't auto_increment a BLOB. In fact, I don't think you can make a BLOB a primary key either. I'm not even sure why you'd want to. There's no way that could perform well.

I'd recommend you rethink your database design. I can guarantee you that you don't really need a LONGBLOB for your primary key. If an INT isn't long enough, then a BIGINT UNSIGNED almost certainly will be. And if not, you can fit a GUID, which has 2^128 unique values, comfortably into a VARCHAR.

Think of it this way - a LONGBLOB can store 2^32 types of data. That's 4GB. If you need that much data to uniquely identify a row in your database, something is very, very wrong.
Was This Post Helpful? 0
  • +
  • -

#3 Pencil  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 7
  • Joined: 27-July 09

Re: Primary key error

Posted 27 July 2009 - 03:56 PM

Ah

It seems that when i was looking at a cheat sheet i got mixed up a bit.
I did not realise that LONGBLOB was a string type.

I will just use a bigint or int.

I have to agree that 4GB would be a bit much for a primary key. ;)

Thanks for the help :)

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1