Deferred Constraints

Deferred Constraints - CS1555 Recitation 5 Objective To...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1 of 4 CS1555 Recitation 5 Objective: To practice more SQL queries on Oracle. Before we start, connect to the server and set the environment variables 1. ssh <username>@unixs.cis.pitt.edu 2. source ~panos/1555/bash.env ________________________________________________________________________ PART 1: _____________________________________________________________________ 1. Use the create statement with the deferred statement mentioned below create table NOTDEF ( ssn number, constraint pk_ssn_1 PRIMARY KEY(ssn) ); create table DEFIMM ( ssn number, constraint pk_ssn_2 PRIMARY KEY(ssn) Deferrable Initially Immediate ); create table DEFDEF ( ssn number, constraint pk_ssn_3 PRIMARY KEY(ssn) Deferrable Initially Deferred ); a) insert into NOTDEF values (1234); insert into NOTDEF values (1234); => primary key constraint violation. The values should be unique. b) insert into DEFIMM values (1234); insert into DEFIMM values (1234); => primary key constraint violation. The values should be unique. c) insert into DEFDEF values (1234); insert into DEFDEF values (1234); commit; => primary key constraint violation. The values should be unique.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Page 2 of 4 2. Run: < set constraint constraint_name deferred > for the constraint set in table DefImm; Run the previous insert again. Do you see any difference?
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern