sql - how do i cascade updates and deletions in oracle? -


i'm trying follow examples in book cascade updates , deletions problem syntax doesnt work in oracle db..

i understand cascade update mean update parent update child , same deletions.. cant figure out syntax oracle.. specific questions book are:

7.5 -- write create table statement employee table. email required , alternate key, , default value of department human resources. cascade updates not deletions department employee.

7.6 -- write create table statement project table. default value maxhours 100. cascade updates not deletions department employee.

7.7 -- write create table statement assignment table. cascade deletions project assignment; not cascade either deletions or updates employee assignment.

i managed created these tables in isql *plus query:

create table department ( departmentname  char(35) not null, budgetcode      char(30) not null, officenumber    char(15) not null, phone           char(12) not null,  constraint departmentpk primary key(departmentname)  );  insert department values (     'administration', 'bc-100-10', 'bldg01-300', '360-285-8100');  create table employee ( employeenumber  int         not null, firstname       char(25)    not null, lastname        char(25)    not null, department      char(35)    default 'human resources' not null, phone           char(12)    null, email           char(30)    not null, departmentname_fk char(35) not null,  constraint employeepk   primary key(employeenumber), constraint employeeak1 unique(email), constraint departmentfk foreign key (departmentname_fk)     references department(departmentname) --on update cascade  --on delete no action   );  create table project ( projectid   int         not null, name        char(30)    not null, department1 char(15)    not null, maxhours    int         default 100 not null, startdate   date        null, enddate     date        null, departmentname_fk1 char(30)   null,   constraint  datecheck check (startdate < enddate), constraint projectidpk   primary key(projectid), constraint departmentfk1 foreign key (departmentname_fk1)     references department(departmentname) -- on update cascade  -- on delete no action  );  create table assignment( projectid       number      not null, employeenumber  number      not null, hoursworked     number      null,  constraint projectidempnumpk primary key(projectid, employeenumber),  constraint projectidfk foreign key(projectid)     references project(projectid), constraint empnumfk foreign key(employeenumber)     references employee(employeenumber) --constraint uniqueemployee unique (employenumber)  --on delete cascade  ); 

but how specify cascading delete , update , specify not to?

did try this?

create table assignment( projectid       number      not null, employeenumber  number      not null, hoursworked     number      null,  constraint projectidempnumpk primary key(projectid, employeenumber),  constraint projectidfk foreign key(projectid)     references project(projectid) on delete cascade  on update no action , constraint empnumfk foreign key(employeenumber)     references employee(employeenumber) on delete no action  on update no action  ); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -