List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:February 16 2006 12:10pm
Subject:Re: primary key
View as plain text  
Hi there,

> Im trying to set up a primary key of server(text), date (date), hour 
> (small int) but when i try to include the server field in the key it 
> replies with
> ADD PRIMARY KEY ( `date` , `hour` , `server` )
> #1170 - BLOB/TEXT column 'server' used in key specification without a 
> key length
> i have googled, but not much is relevant to my example i dont think..

Well, you could start with the documentation.

"server" apparently, is a blob-type column. 

Lo and behold, the table definition:
> CREATE TABLE `exim` (
>    `date` date NOT NULL default '0000-00-00',
>    `server` longtext NOT NULL,

Yep. A BLOB column. Why, I wonder.

Either way - check the error message, read it. From what I can read
from it - and the MySQL documentation - you cannot "just" create
a constraint/index on a BLOB column.

>    `hour` tinyint(4) NOT NULL default '0',
>    `count` smallint(6) NOT NULL default '0',
>    PRIMARY KEY  (`date`,`hour`),
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='exim realtime stats';

Martijn Tonies
Database Workbench - development tool for MySQL, and more!
Upscene Productions
My thoughts:
Database development questions? Check the forum!
primary keyRonan16 Feb
  • Re: primary keyAlec.Cawley16 Feb
  • Re: primary keyMartijn Tonies16 Feb