The ALTER command allows you to quickly and easily add a foreign key constraint. Whether you want to Add Foreign Key Using ALTER in MySQL Workbench or another DB management tool, clicking through the process and doing it step by step is easy, and the result is clean, use the foreign key that guarantees data integrity within your database.
MySQL alter table set column unique
Code: Select all
ALTER TABLE contactsADD CONSTRAINT contacts_unique UNIQUE (reference_number);
MySQL alter add foreign key
Code: Select all
ALTER TABLE ordenes ADD ticket VARCHAR(50) NOT NULL;ALTER TABLE ordenes ADD CONSTRAINT fk_ticket FOREIGN KEY (ticket) REFERENCES tickets(ticket);