Mansoor H
Mansoor H

Reputation: 604

how to delete foreign key in mysql

Am using mysql and trying to drop foreign constraint, but i can't to delete that key.

SHOW CREATE TABLE xxxx;

its shows,

CREATE TABLE `xxxx` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `user_id` int(11) NOT NULL,
 `name` text NOT NULL,
 `article_title` text NOT NULL,
 `created_at` datetime NOT NULL,
 `last_modified_at` datetime NOT NULL,
 `latest_version` tinyint(4) NOT NULL,
 `status` tinyint(4) NOT NULL,
 `is_deleted` enum('0','1') NOT NULL,
 `deleted_time` datetime NOT NULL,
 `manual_authorgroup_data` text NOT NULL,
 PRIMARY KEY (`id`),
 KEY `user_id` (`user_id`),
 CONSTRAINT `fk_users_xxxx_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1

How to fix this issue, please help me.

Upvotes: 0

Views: 2267

Answers (1)

suguna
suguna

Reputation: 811

Try this,

ALTER TABLE `xxxx`
DROP FOREIGN KEY'fk_users_xxxx_user_id'

Upvotes: 1

Related Questions