Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

mysql delet from the child table when we delete the rows from the parent

MySQL ON DELETE CASCADE

syntax:
CREATE TABLE Employee (  
  emp_id int(10) NOT NULL,  
  ...
  ...
  PRIMARY KEY (emp_id)  
);  

CREATE TABLE Payment (  
  payment_id int(10) PRIMARY KEY NOT NULL,  
  emp_id int(10) NOT NULL,  
  ...
  ...
  FOREIGN KEY (emp_id) REFERENCES Employee (emp_id) ON DELETE CASCADE  
);  
Source by www.javatpoint.com #
 
PREVIOUS NEXT
Tagged: #mysql #delet #child #table #delete #rows #parent
ADD COMMENT
Topic
Name
5+2 =