Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbwxn-0006OH-OR for pgsql-sql@arkaria.postgresql.org; Wed, 06 Apr 2022 04:08:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbwxm-0002FF-Ja for pgsql-sql@arkaria.postgresql.org; Wed, 06 Apr 2022 04:08:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbwxm-0002F4-BH for pgsql-sql@lists.postgresql.org; Wed, 06 Apr 2022 04:08:10 +0000 Received: from mail-yb1-xb34.google.com ([2607:f8b0:4864:20::b34]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbwxj-0007V7-Br for pgsql-sql@lists.postgresql.org; Wed, 06 Apr 2022 04:08:09 +0000 Received: by mail-yb1-xb34.google.com with SMTP id w134so1938921ybe.10 for ; Tue, 05 Apr 2022 21:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=6NThghtqvjLfus3Sqhx8jkjqfIZTklmkUJNBryfZVEo=; b=kwg3DQaG2zeKHMcb9/Bn5Lp3LxMhESuhsfN4yngv+1O38B1RMdeIMtv2vnVOmVIfv9 x3be4VTWACQgX4ZbOgO3TqBu35lLMwZZAWOKJnWpq9w21fVucpIoBiR1L8CtWZPNychY Wu0O+2cPhTmPuAExAN0G7yoOzP9Tdg916iTh93gyh52UrnhzrNVV1N7DYtwvnRkuW5JP 98q9t2mIUyUVU+9dLvTbjLBP3/J2bg2qKQagOSkhRd0GuXB69eYP6QVGQ7mF6sgF9xZj W3RKyQaQZkTCPqoX9/NoQmOuX3yF8dI0czYhJy10Xiosr3NoaW8l1U+66K9HMGdkYm3M s8Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=6NThghtqvjLfus3Sqhx8jkjqfIZTklmkUJNBryfZVEo=; b=Qthruz9wllbkMU1up1/27TNdU3BdYJ1yuUeUZ9LSSrDg5f127U/la4NaUzlRWRKraW CGwuX5aKoRCk3w1L+xZRNssQZblCAXyP/aUndsMZpzvvQFLvIjGqhU5ePqJUogxaNaD5 iXNXn1IMAZCqBNCmcR8eSenssSa3ig+NvHujEL6okyG225Fu8vYi9KLTmE1fwNA2Xbc+ zA9HMQ4wlzCPsv81KA6NVwm9aC0i1JktblihT67lfJUiqDLKemtj3bleOSrWqItDVpQm 66N5nrkxcyR2ufqcwcQZ0gljyN3Y4KJDWBt1B07L1/K+6Zm9OMT86wSRmqVpJLHi2lNe ZQfA== X-Gm-Message-State: AOAM5316bgs8cf67AMxY/U7XXWo2DMNeAtQIh7jbwDiUad6Sdj6H3+MC 27A1df3YSWWX4w7Hue6uT0lHK2YZXHbr2LpNe6ZTcWpW6q5B7NZS X-Google-Smtp-Source: ABdhPJyoFLgm3EvGQL3RReWoi8GM/Y3gCUO3ZXmnjW5MrD7HU9qGka44cPdD6+xFO+4PIQN52p9eMWBlmoqU+j8WuIY= X-Received: by 2002:a25:e30a:0:b0:625:3d53:91b7 with SMTP id z10-20020a25e30a000000b006253d5391b7mr5005310ybd.499.1649218086472; Tue, 05 Apr 2022 21:08:06 -0700 (PDT) MIME-Version: 1.0 From: Jian He Date: Wed, 6 Apr 2022 09:37:55 +0530 Message-ID: Subject: Does postgresql know the check condition is valid or not. or can check deduce from multiple conditions To: pgsql-sql Content-Type: multipart/alternative; boundary="000000000000338f8505dbf482e7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000338f8505dbf482e7 Content-Type: text/plain; charset="UTF-8" If the question is stupid, please tell me why. postgresql - How to query check the constraint is valid or not - Stack Overflow Postgres 14 | db<>fiddle (dbfiddle.uk) CREATE TABLE emp (test_check int check ( test_check >1 and test_check < 0 )); alter table emp VALIDATE CONSTRAINT emp_test_check_check;``` select * from pg_constraint where conname = 'emp_test_check_check'; Even with the above mentioned step, does postgresql know above check constraint condition always false. another similar question: can postgresql deduce from CREATE TABLE emp1 (test_check int check ( test_check >1 and test_check > 10 )); to CREATE TABLE emp1 (test_check int check ( test_check > 10 )); --000000000000338f8505dbf482e7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

If the question= =C2=A0is stupid, please tell me why.=C2=A0

postg= resql - How to query check the constraint is valid or not - Stack Overflow<= /a>
Postgres 14 | db<>fiddle (dbfiddle.uk)=

CREATE=C2=A0TABLE=C2=A0emp (test_check int=C2=A0check=C2=A0( test_check= >1=C2=A0and=C2=A0test_check <=C2=A00=C2=A0));

alter table emp =C2=A0VALID= ATE CONSTRAINT emp_test_check_check;```

select * from pg_constraint where connam= e =3D 'emp_test_check_check';

Even with the above mentioned = step, does postgresql know above check constraint condition always false.


an= other similar question:
can postgresql deduce from
CREATE TABLE emp1 = (test_check int check ( test_check >1 and test_check > 10 ));

to

CREATE TABLE e= mp1 (test_check int check ( test_check > 10 ));

--000000000000338f8505dbf482e7--