mysql - In My Project i have x_user_module_perm table for which i need to keep one primary key and one composite primary key -
i using syntax :-
create table `x_user_module_perm` ( `id` bigint(20) not null auto_increment, `user_id` bigint(20) null default null, `module_id` bigint(20) null default null, `create_time` datetime null default null, `update_time` datetime null default null, `added_by_id` bigint(20) null default null, `upd_by_id` bigint(20) null default null, `is_allowed` int(11) not null default '1', primary key (`id`), primary key (`user_id`,`module_id`), key `x_user_module_perm_idx_module_id` (`module_id`), key `x_user_module_perm_idx_user_id` (`user_id`), constraint `x_user_module_perm_fk_module_id` foreign key (`module_id`) references `x_modules_master` (`id`) on delete cascade on update cascade, constraint `x_user_module_perm_fk_user_id` foreign key (`user_id`) references `x_portal_user` (`id`) on delete cascade on update cascade ) ;
i getting error cannot use 2 primary key's
do possible, guy's please guide me !!!
try changing primary key (user_id,module_id)
unique index(user_id,module_id)
Comments
Post a Comment