Jump to content

Archived

This topic is now archived and is closed to further replies.

live_ex3me

what's wrong with this ?

Recommended Posts

hi there.. i have this code:
[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)
)
[/code]

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

[b]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[/b]

any help ?

Share this post


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

Share this post


Link to post
Share on other sites
[quote author=shoz link=topic=107367.msg430729#msg430729 date=1157734766]
If you want the PRIMARY KEY to be on BOTH "primary_id" and "type" then you have to make type NOT NULL as well.
[code]
ALTER TABLE tablename MODIFY type ENUM('post', 'thread') NOT NULL DEFAULT 'post',
[/code]
[/quote]
thanx a lot  :-*

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.