Reputation:
I'm new to cascades, I just did something like this,
CREATE TABLE IF NOT EXISTS `test_deck_link_2`(
`id` INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
`deck_id` INTEGER NOT NULL,
FOREIGN KEY (deck_id) REFERENCES test_deck (id)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
INSERT INTO decks (user_id,header)VALUES(1,"foo");
ALTER TABLE deck_ratings
ADD CONSTRAINT `deck_rating_contraint`
FOREIGN KEY (`deck_id` )
REFERENCES `decks` (`deck_id` )
ON DELETE CASCADE
How can I view these inside of my database? As of now I can only see the structure of the rows, but not the foreign keys or cascades on them.
Upvotes: 8
Views: 5318
Reputation: 172638
You can try to execute this query:
SELECT * FROM information_schema.REFERENTIAL_CONSTRAINTS
or you can use
SHOW CREATE TABLE `yourtablename`
which will give you the definition of the table along with the foreign key constraints.
Upvotes: 17