Untitled
unknown
plain_text
17 days ago
661 B
6
Indexable
create database nax1; use nax1; CREATE TABLE departments ( dept_id INT PRIMARY KEY, dept_name VARCHAR(50) ); CREATE TABLE employees ( emp_id INT PRIMARY KEY, name VARCHAR(50), dept_id INT, FOREIGN KEY (dept_id) REFERENCES departments(dept_id) ON DELETE CASCADE ON UPDATE CASCADE ); insert into departments(dept_id,dept_name) values(1,'IT'), (2,'HR'),(3,'FINANCE'); SELECT * FROM DEPARTMENTS; insert into employees(emp_id, name,dept_id) values(111,'A',2), (222,'B',2),(333,'F',1), (444,'E',3),(555,'G',1); SELECT* FROM EMPLOYEES; update departments set dept_id=5 where dept_id=3; delete from departments where dept_id=5;
Editor is loading...
Leave a Comment