List:General Discussion« Previous MessageNext Message »
From:Robert (IMI) Date:July 7 1999 7:04pm
Subject:Setting a Primary Key
View as plain text  
Ok a simple question or I think it is.. I read the manual on setting a Primary Key, and
this is what I came up with.. in a table called users I have a field called username that
I was going to make the Primary Key.. someone had suggested I set the key to that field
since its the main tie between tables.. 

I typed in the following and got the following error.. 
 
mysql> ALTER TABLE users ADD PRIMARY KEY (username);
ERROR 1121: Column 'username' is used with UNIQUE or INDEX but is not defined as NOT NULL

I then figured I got the error because the field was not set to NOT NULL so I made several
attempts setting a NOT NULL to the field.. 

mysql> ALTER TABLE users NOT NULL (username);
ERROR 1064: You have an error in your SQL syntax near 'NOT NULL (username)' at line 1
mysql> ALTER TABLE users MODIFY username NOT NULL;
ERROR 1064: You have an error in your SQL syntax near 'NOT NULL' at line 1
mysql> ALTER TABLE users MODIFY (username) NOT NULL;
ERROR 1064: You have an error in your SQL syntax near '(username) NOT NULL' at line 1

Any hints on what I am missing.. ?



Robert Saunders
robert@stripped



Thread
Setting a Primary KeyIMI)7 Jul
  • Re: Setting a Primary KeyBenjamin Pflugmann7 Jul