Problem in on delete no action why?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • minorcoder
    New Member
    • Apr 2010
    • 1

    Problem in on delete no action why?

    while i am trying to execute the following query it shows error. i need to create such type relation between 3 table. here i am showing example. this also show error.
    Code:
    create table tbl1(
    	id1	number primary key,
    	name1	varchar2(10)
    );
    
    create table tbl2(
    	id2	number,
    	name2	varchar2(10) primary key);
    
    create table tbl3(
    	id3	number,
    	name3	varchar2(10),
    	foreign key (id3) references tbl1(id1),
    	foreign key (name3) references tbl2(name2) on delete no action
    );
    but when i run the following code it shows no error
    Code:
    create table tbl1(
    	id1	number primary key,
    	name1	varchar2(10)
    );
    
    create table tbl2(
    	id2	number,
    	name2	varchar2(10) primary key);
    
    create table tbl3(
    	id3	number,
    	name3	varchar2(10),
    	foreign key (id3) references tbl1(id1),
    	foreign key (name3) references tbl2(name2) on delete cascade
    );
    why?????
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    and the error is ...

    Comment

    • magicwand
      New Member
      • Mar 2010
      • 41

      #3
      Code:
      and the error is ...
      probably something like "ON DELETE NO ACTION is no combination of keywords Oracle supports. Please look up the CREATE TABLE statement ..."

      Comment

      • rski
        Recognized Expert Contributor
        • Dec 2006
        • 700

        #4
        Originally posted by magicwand
        Code:
        and the error is ...
        probably something like "ON DELETE NO ACTION is no combination of keywords Oracle supports. Please look up the CREATE TABLE statement ..."
        I think there is ON DELETE NO ACTION

        Comment

        • Oralloy
          Recognized Expert Contributor
          • Jun 2010
          • 988

          #5
          I may be confused here, but I think you're mistaking the "DELETE NO ACTION" DML statement for the "ON DELETE NO ACTION" clause.

          This link was on the page you gave. It referrs to the "On Delete" clause.

          Comment

          • magicwand
            New Member
            • Mar 2010
            • 41

            #6
            @rski:

            oops, never noticed that.

            Sorry ...

            Comment

            • amitpatel66
              Recognized Expert Top Contributor
              • Mar 2007
              • 2358

              #7
              Its not required to say "ON DELETE NO ACTION" because oracle supports ON DELETE CASCADE/ON DELETE SET NULL and if you do not specify ON DELETE CASCADE or ON DELETE SET NULL, by default it is set to "NO ACTION".

              Try this:

              [code=oracle]
              create table tbl3(
              id3 number,
              name3 varchar2(10),
              foreign key (id3) references tbl1(id1),
              foreign key (name3) references tbl2(name2));
              [/code]

              The above code will by default behave as "ON DELETE NO ACTION"

              Comment

              Working...