Jump to content


Photo

what's wrong with this ?


  • Please log in to reply
2 replies to this topic

#1 live_ex3me

live_ex3me
  • Members
  • PipPip
  • Member
  • 15 posts
  • LocationRomania

Posted 08 September 2006 - 04:52 PM

hi there.. i have this code:
CREATE TABLE " . TABLE_PREFIX . "deletionlog (
	primaryid INT UNSIGNED NOT NULL DEFAULT '0',
	type ENUM('post', 'thread') DEFAULT 'post',
	userid INT UNSIGNED NOT NULL DEFAULT '0',
	username VARCHAR(100) NOT NULL DEFAULT '',
	reason VARCHAR(125) NOT NULL DEFAULT '',
	PRIMARY KEY (primaryid, type)
)

but.. it doesn't work.. it gives me this error:

MySQL Error  : All parts of a PRIMARY KEY must be NOT NULL;  If you need NULL in a key, use UNIQUE instead
Error Number : 1171


any help ?
There is no place like 127.0.0.1 !

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 08 September 2006 - 04:59 PM

If you want the PRIMARY KEY to be on BOTH "primary_id" and "type" then you have to make type NOT NULL as well.
ALTER TABLE tablename MODIFY type ENUM('post', 'thread') NOT NULL DEFAULT 'post',


#3 live_ex3me

live_ex3me
  • Members
  • PipPip
  • Member
  • 15 posts
  • LocationRomania

Posted 08 September 2006 - 05:03 PM

If you want the PRIMARY KEY to be on BOTH "primary_id" and "type" then you have to make type NOT NULL as well.

ALTER TABLE tablename MODIFY type ENUM('post', 'thread') NOT NULL DEFAULT 'post',

thanx a lot  :-*
There is no place like 127.0.0.1 !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users