Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding constraints in phpMyAdmin

I feel like I'm being stupid, but I can't find anywhere on the phpMyAdmin interface to add constraints to foreign keys e.g. CASCADE ON DELETE

I've looked for similar questions on here and on the phpMyAdmin wiki but I can't find anything about it.

I realise I could do this via the query interface, but I'd like to know how to do it through the graphical interface.

like image 914
Alex Avatar asked Feb 29 '12 13:02

Alex


People also ask

What is constraint phpMyAdmin?

MySQL CONSTRAINT is used to define rules to allow or restrict what values can be stored in columns. The purpose of inducing constraints is to enforce the integrity of a database. MySQL CONSTRAINTS are used to limit the type of data that can be inserted into a table.

How do I show constraints on a table in phpMyAdmin?

Click the "Structure" tab. Click "Relation view". Under the foreign key constraints, click the "Choose column to display" drop down and make a choice.

How do I create a constraint in MySQL?

The syntax for creating a unique constraint using an ALTER TABLE statement in MySQL is: ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE (column1, column2, ... column_n); table_name.

How do you add constraints to a table?

The basic syntax of an ALTER TABLE command to ADD CHECK CONSTRAINT to a table is as follows. ALTER TABLE table_name ADD CONSTRAINT MyUniqueConstraint CHECK (CONDITION);


1 Answers

First, you should have your storage engine as InnoDB. Then select a table and go to 'Structure' tab.

Under the table you will see 'Relation view', click it. From there you could add constraints.

like image 132
utsikko Avatar answered Oct 02 '22 12:10

utsikko