Mike's Pub -> Discussion Corner -> Questions on Web Programming (Perl/PHP)

 optimization issue [ Reply ] [ Back to Index ] Top Bottom

Author : karen
Date: 2002/11/03 00:58

Error 
Tried to run an optimizaiton command:
alter table nuke_comments add index idx_pid (pn_pid)
;
Got this error message:

SQL-query :  

alter table nuke_comments add index idx_pid (pn_pid)

MySQL said: 


Column 'pn_pid' is used with UNIQUE or INDEX but is not defined as NOT NULL

 Re: optimization issue [ Reply ] [ Back to Index ] Top Bottom

Author : Mike
Date: 2002/11/04 12:24

From the MySQL documentation at http://www.mysql.com/doc/en/CREATE_INDEX.html :

...
Note that you can only add an index on a column that can have NULL values or on a
BLOB/TEXT column if you are using MySQL Version 3.23.2 or newer and are using the MyISAM
table type. 
...

So if you can't upgrade your MySQL version, you'll need to adapt the nuke_comments table
so that pn_pid column is defined as NOT NULL, with something like :

ALTER TABLE nuke_comments MODIFY pn_pid int(11) DEFAULT '0' NOT NULL;

Same thing for any other columns it might be complaining about : find the current column
definition, and add NOT NULL at the end :-)

 Reply [ Back to Index ] Top Bottom
Name : or OpenID OpenID Login
E-mail : (optional)
Subject :
Message :
MathGuard security question: 0 + 0 =
 

Mike's Pub -> Discussion Corner -> Questions on Web Programming (Perl/PHP)