List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:April 20 1999 7:11pm
Subject:Re: Problem with create unique index
View as plain text  
Miguel, all indexed columns must be explicitly declared NOT NULL.
You should do this:

ALTER TABLE users CHANGE alias alias <the current definition> NOT NULL;

For example, if the alias field is a CHAR(16), then you would do:

ALTER TABLE users CHANGE alias alias CHAR(16) NOT NULL;
CREATE UNIQUE INDEX alias_index ON USERS (alias);

In general, I think it's a good idea to declare all columns NOT
NULL unless you intend on using a NULL value.  That way it will
keep you from making unintentional mistakes (which are very easy
to do with NULL values, and often very hard to track down).

Tim

On Tue, Apr 20, 1999 at 07:38:58PM -0100, Miguel Oliveira wrote:
> CREATE UNIQUE INDEX alias_index ON users(alias)
> 
> Couldn't  create  the  alias  index on the users table!  (Column 'alias' is
> used with UNIQUE or INDEX but is not defined as NOT NULL)
Thread
Problem with create unique indexMiguel Oliveira20 Apr
  • Re: Problem with create unique indexPaul DuBois20 Apr
  • Re: Problem with create unique indexThimble Smith20 Apr
  • Re: Problem with create unique indexSasha Pachev20 Apr
  • Re: problem with mysql and myodbc--from saikoneruTimothy Houck22 Sep
Re: problem with mysql and myodbc--from saikoneruAjit Kolhatkar22 Sep