How can I avoid getting this MySQL error Incorrect column specifier for column topic_id ?
MySQL Error...
#1063 - Incorrect column specifier for column 'topic_id'
SQL Schema...
CREATE TABLE discussion_topics (
topic_id char(36) NOT NULL AUTO_INCREMENT,
project_id char(36) NOT NULL,
topic_subject VARCHAR(255) NOT NULL,
topic_content TEXT default NULL,
date_created DATETIME NOT NULL,
date_last_post DATETIME NOT NULL,
created_by_user_id char(36) NOT NULL,
last_post_user_id char(36) NOT NULL,
posts_count char(36) default NULL,
PRIMARY KEY (topic_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
You cannot auto increment the
char
values. It should beint
orlong
(integers or floating points). Try with this,Hope this helps
The
auto_increment
property only works for numeric columns (integer and floating point), notchar
columns:I was having the same problem, but using Long type. I changed for INT and it worked for me.
Quoting the doc:
In your case, you're trying to apply
AUTO_INCREMENT
modifier tochar
column. To solve this, either dropAUTO_INCREMENT
altogether (that means you'll have to generate a unique id on the application level) or just changetopic_id
type to the relevant integer one.As a sidenote, it makes little sense using
char(36)
to store the posts count, so that column's type probably has to be changed as well. It looks like you're going this way to prevent integer overflow - but if you're dealing with more than18446744073709551615
posts (the biggest number that can be stored inBIGINT UNSIGNED
column) in a single topic, you have far bigger problem on your side probably. )To use
AUTO_INCREMENT
you need to deifne column asINT
or floating-point types, notCHAR
.AUTO_INCREMENT
use only unsigned value, so it's good to useUNSIGNED
as well;