Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5996391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:05:48+00:00 2026-05-23T00:05:48+00:00

I have the following test case: DROP SCHEMA IF EXISTS test CASCADE; CREATE SCHEMA

  • 0

I have the following test case:

DROP SCHEMA IF EXISTS test CASCADE;
CREATE SCHEMA test;

CREATE TABLE test.quz (
  foo int,
  bar int,
  PRIMARY KEY ( foo, bar )
);
CREATE TABLE test.quuz (
  foo int,
  bar int,
  baz int,
  PRIMARY KEY ( foo, bar ),
  FOREIGN KEY ( foo, bar ) REFERENCES test.quz MATCH FULL
);

INSERT INTO test.quz VALUES ( 1, 2 );
INSERT INTO test.quuz VALUES ( 1, 2, 3 );

However, even when deferred this doesn’t seem to work.

BEGIN;
  SET CONSTRAINTS ALL DEFERRED;
  UPDATE test.quz SET bar = 100 where bar = 2;
  UPDATE test.quuz SET bar = 100 where bar = 2;
  COMMIT;
END;

Is there any reason? Can this task be done without the terseness of manually deleteing and re-inserting rows?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:05:48+00:00Added an answer on May 23, 2026 at 12:05 am

    DEFERRABLE means that constraints are checked at the end of each statement. DEFERRABLE INITIALLY DEFERRED, means that constraints are checked at the end of the transaction.

    This should work in your case:

    CREATE TABLE test.quuz (
      foo int,
      bar int,
      baz int,
      PRIMARY KEY ( foo, bar ),
      FOREIGN KEY ( foo, bar ) REFERENCES test.quz MATCH FULL DEFERRABLE INITIALLY DEFERRED
    );
    
    ...
    
    BEGIN;
      UPDATE test.quz SET bar = 100 where bar = 2;
      UPDATE test.quuz SET bar = 100 where bar = 2;
    COMMIT;
    

    This will probably work too:

    CREATE TABLE test.quuz (
      foo int,
      bar int,
      baz int,
      PRIMARY KEY ( foo, bar ),
      FOREIGN KEY ( foo, bar ) REFERENCES test.quz MATCH FULL DEFERRABLE
    );
    
    ...
    
    BEGIN;
      SET CONSTRAINTS ALL DEFERRED;
      UPDATE test.quz SET bar = 100 where bar = 2;
      UPDATE test.quuz SET bar = 100 where bar = 2;
    COMMIT;
    

    Unless I am mistaking, the issue in your definitions is that you don’t mark your constraints as deferrable. So Postgres treats them as NOT DEFERRABLE INITIALLY IMMEDIATE (i.e. the default in Postgres in spite of the SQL standard, the rational being that it is fastest) irrespective of SET CONSTRAINTS (which only affects deferrable constraints).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT
I have the following program: ~/test> cat test.cc int main() { int i =
I am using Linq to NHibernate. I have a following test case : [TestMethod]
I have the following test case in eclipse, using JUnit 4 which is refusing
I have the following test case xaml. <Window.Resources> <XmlDataProvider x:Key=testDS1> <x:XData> <root xmlns=> <item>1</item>
I have the following django test case that is giving me errors: class MyTesting(unittest.TestCase):
I have written the following simple test in trying to learn Castle Windsor's Fluent
I have the following example class: Test.h: @interface Test : UIButton { NSString *value;
Suppose I have following string: String asd = this is test ass this is
For simplicity, i have the following file named test.jsp: <script language=javascript> alert(a$b.replace(/\$/g,k)); </script> I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.