Another handy feature of the Namespaces is their cascading effect. If, for example, we delete the testing Namespace, all the objects and the resources running inside it will be removed as well.
xxxxxxxxxx
kubectl delete ns testing
kubectl -n testing get all
xxxxxxxxxx
CREATE TBALE parent_table_p (
id INT PRIMARY KEY
)
CREATE_TABLE child_table_c(
id INT PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id) REFERENCES parent_table_p(id) ON DELETE CASCADE
)
xxxxxxxxxx
The ON DELETE CASCADE clause specifies that if a row in the
table A is deleted, any rows in the table B that reference the deleted
row will also be deleted.
xxxxxxxxxx
CREATE TABLE child_table
(
column1 datatype [ NULL | NOT NULL ],
column2 datatype [ NULL | NOT NULL ],
CONSTRAINT fk_name
FOREIGN KEY (child_col1, child_col2, child_col_n)
REFERENCES parent_table (parent_col1, parent_col2, parent_col_n)
ON DELETE CASCADE
[ ON UPDATE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ]
);
xxxxxxxxxx
CREATE TABLE Enroll (
sno INT,
cno INT,
jdate date,
PRIMARY KEY(sno,cno),
FOREIGN KEY(sno)
REFERENCES Student(sno)
ON DELETE CASCADE
FOREIGN KEY(cno)
REFERENCES Course(cno)
ON DELETE CASCADE
);