mysql alter add foreign key
snippet in sql

alter table add column forigen key mysql

user9365

ALTER TABLE tryholpz_demo07.core_modules 
ADD COLUMN belongs_to_role INT, 
ADD FOREIGN KEY core_modules(belongs_to_role) REFERENCES role_specific_modules_info(id) ON DELETE CASCADE

how to connect database foreign key in mysql

user6070


        
            
        
     CREATE TABLE products(
    productId INT AUTO_INCREMENT PRIMARY KEY,
    productName varchar(100) not null,
    categoryId INT NOT NULL,
    CONSTRAINT fk_category
    FOREIGN KEY (categoryId) 
    REFERENCES categories(categoryId)
        ON UPDATE CASCADE
        ON DELETE CASCADE
) ENGINE=INNODB;

mysql alter add foreign key

user1099

ALTER TABLE ordenes ADD ticket VARCHAR(50) NOT NULL;
ALTER TABLE ordenes ADD CONSTRAINT fk_ticket FOREIGN KEY (ticket) REFERENCES tickets(ticket);

mysql alter add foreign key

user1661

ALTER TABLE ordenes ADD ticket VARCHAR(50) NOT NULL;
ALTER TABLE ordenes ADD CONSTRAINT fk_ticket FOREIGN KEY (ticket) REFERENCES tickets(ticket);
// I'm Horrible Hyena

create table foreign key

user1483


CREATE TABLE Orders
(

   
OrderID int NOT NULL,

   
OrderNumber int NOT NULL,

   
PersonID int,

   
PRIMARY KEY (OrderID),

   
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)

);