Return-Path: <oracle-l-bounce@freelists.org>
X-Original-To: oracle-l@orafaq.com
Delivered-To: oracle-l@orafaq.com
Received: from puck1183.startdedicated.com (localhost [127.0.0.1])
 by puck1183.startdedicated.com (Postfix) with ESMTP id 0EFF5196159F
 for <oracle-l@orafaq.com>; Mon, 10 Oct 2016 16:15:11 +0200 (CEST)
Received: from turing.freelists.org (turing.freelists.org [206.53.239.180])
 by puck1183.startdedicated.com (Postfix) with ESMTPS
 for <oracle-l@orafaq.com>; Mon, 10 Oct 2016 16:15:10 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 58D6A2F461;
 Mon, 10 Oct 2016 10:15:09 -0400 (EDT)
X-Virus-Scanned: Debian amavisd-new at turing.freelists.org
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id KOVZed6uRVSO; Mon, 10 Oct 2016 10:15:09 -0400 (EDT)
Received: from turing.freelists.org (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 288412F415;
 Mon, 10 Oct 2016 10:14:56 -0400 (EDT)
Received: with ECARTIS (v1.0.0; list oracle-l); Mon, 10 Oct 2016 10:13:34 -0400 (EDT)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 232C02A83B
 for <oracle-l@freelists.org>; Mon, 10 Oct 2016 10:13:34 -0400 (EDT)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id j7T-GWp_gSdf for <oracle-l@freelists.org>;
 Mon, 10 Oct 2016 10:13:34 -0400 (EDT)
Received: from mail-it0-f54.google.com (mail-it0-f54.google.com [209.85.214.54])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id DD22D29D6A
 for <oracle-l@freelists.org>; Mon, 10 Oct 2016 10:13:33 -0400 (EDT)
Received: by mail-it0-f54.google.com with SMTP id o19so80634147ito.1
        for <oracle-l@freelists.org>; Mon, 10 Oct 2016 07:13:33 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:cc;
        bh=Ve+L1Ne4sKHavFs3FGP0hJERLTciuh+oyDTdVTgEiZo=;
        b=Z8/NYeCHT8K2l+iY759rw/p8j+mi5di4FJbYoJsJRx9hRS44Wvr8DdCaFWtndj3J8N
         ClIQLwS6i6CdVW0k7aLJ2SjYdyaCdpc6SH2+pxqo5FGnc91zrE5EPv7k6lZ/vItjKr3p
         lxnR9NJEfAHLLN15waI30oBNLJbeEKKB1s/CMKsY+6jgtVtdP5G+FJXYIA7v7x1a5GZ4
         1kQYykBuhw/uEzKnE0+IizRBmqexPUqa2iL8e2h1yHBZMRJmRZHwkDxaB6KbaJA5kY+2
         3/zPI8N9IXKRxajyQ4WY8xSTachykXGD8SA+VJQFCuzJ5kuxlFIG9GaNPh1cI5Qgqw0Q
         md+g==
X-Gm-Message-State: AA6/9RlRshfUysHQaZCbGpgA5uAvesUl5qe0TL/bUpFlehSu7GLcgryVo78NwOeK/B3+eJaYX5ZDeAIfj5hmrA==
X-Received: by 10.36.211.215 with SMTP id n206mr10708602itg.112.1476108812880;
 Mon, 10 Oct 2016 07:13:32 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.107.135.199 with HTTP; Mon, 10 Oct 2016 07:13:32 -0700 (PDT)
In-Reply-To: <4812A130-901F-429D-AA1D-4CDB9DB20CB4@gmail.com>
References: <4812A130-901F-429D-AA1D-4CDB9DB20CB4@gmail.com>
From: Toon Koppelaars <toon.koppelaars@rulegen.com>
Date: Mon, 10 Oct 2016 16:13:32 +0200
Message-ID: <CAA9w=EvH1x3dv-wuqb5YtHdUv9Z+7YQboez=W4Bt2v32V-yyyw@mail.gmail.com>
Subject: Re: strange constraint behavior
To: djeday84@gmail.com
Cc: oracle-l-freelists <oracle-l@freelists.org>
Content-Type: multipart/alternative; boundary=001a1145e1ca713172053e835da9
X-archive-position: 66440
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: toon.koppelaars@rulegen.com
Precedence: normal
Reply-To: toon.koppelaars@rulegen.com
List-help: <mailto:ecartis@freelists.org?Subject=help>
List-unsubscribe: <oracle-l-request@freelists.org?Subject=unsubscribe>
List-software: Ecartis version 1.0.0
List-Id: oracle-l <oracle-l.freelists.org>
X-List-ID: oracle-l <oracle-l.freelists.org>
List-subscribe: <oracle-l-request@freelists.org?Subject=subscribe>
List-owner: <mailto:mark.bobak@proquest.com>
List-post: <mailto:oracle-l@freelists.org>
List-archive: <http://www.freelists.org/archives/oracle-l>
X-list: oracle-l
--001a1145e1ca713172053e835da9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

In your 1st query, very likely the optimizer has injected the constraint
text 'FLAG IS NOT NULL' and through transitive closure it then generated a
"NULL IS NOT NULL" filter predicate.

If you show us the execution plan, we can verify this.


On Mon, Oct 10, 2016 at 3:48 PM, Anton Bushmelev <djeday84@gmail.com> wrote=
:

> hello, look at new patch from developer and found strange construction,
> here I=E2=80=99ll try to reproduce what they want to do:
>
> create table tt as select level id from dual connect by level <=3D100;
> alter table tt add flag varchar2(50)  default '' not null ;
> Table altered.
>
> select dump (flag,8 ) as dmp from tt ;
>
> DMP
> ----------
> NULL
> NULL
> =E2=80=A6..
> NULL
>
>
>  select count (*) from tt where flag is null;
>
>   COUNT(*)
> ----------
>          0
>
> select count (*) from tt where flag is not null;
>
>   COUNT(*)
> ----------
>        100
>
>
> How it is possible ? =3D)))
>
>
> ps: if I add default *null, *then all goes well:
>
>  alter table tt add flag varchar2(50)  default null not null ;
> alter table tt add flag varchar2(50)  default null not null
>             *
> ERROR at line 1:
> ORA-01758: table must be empty to add mandatory (NOT NULL) column
>
> create table tt as select level id from dual connect by level <=3D100;
>  alter table tt add flag varchar2(50)  default null not null ;
> alter table tt add flag varchar2(50)  default null not null
>             *
> ERROR at line 1:
> ORA-01758: table must be empty to add mandatory (NOT NULL) column
>
>
> ps: sorry for my English
>
>



--=20
Toon Koppelaars
RuleGen BV
Toon.Koppelaars@RuleGen.com
www.RuleGen.com
TheHelsinkiDeclaration.blogspot.com

(co)Author: "Applied Mathematics for Database Professionals"
www.rulegen.com/am4dp-backcover-text

--001a1145e1ca713172053e835da9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">In your 1st query, very likely the optimizer has injected =
the constraint text &#39;FLAG IS NOT NULL&#39; and through transitive closu=
re it then generated a &quot;NULL IS NOT NULL&quot; filter predicate.<div><=
br></div><div>If you show us the execution plan, we can verify this.</div><=
div><br></div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quot=
e">On Mon, Oct 10, 2016 at 3:48 PM, Anton Bushmelev <span dir=3D"ltr">&lt;<=
a href=3D"mailto:djeday84@gmail.com" target=3D"_blank">djeday84@gmail.com</=
a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-w=
rap:break-word"><div>hello, look at new patch from developer and found stra=
nge construction, here I=E2=80=99ll try to reproduce what they want to do:<=
/div><div><br></div><div>create table tt as select level id from dual conne=
ct by level &lt;=3D100;=C2=A0</div><div>alter table tt add flag varchar2(50=
) =C2=A0default &#39;&#39; not null ;</div><div>Table altered.</div><div><b=
r></div><div>select dump (flag,8 ) as dmp from tt ;</div><div><br></div><di=
v>DMP</div><div>----------</div><div>NULL</div><div>NULL</div><div>=E2=80=
=A6..</div><div>NULL</div><div><br></div><div><br></div><div>=C2=A0select c=
ount (*) from tt where flag is null;</div><div><br></div><div>=C2=A0 COUNT(=
*)</div><div>----------</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00</div>=
<div><br></div><div>select count (*) from tt where flag is not null;</div><=
div><br></div><div>=C2=A0 COUNT(*)</div><div>----------</div><div>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0100</div><div><br></div><div><br></div><div>How it is p=
ossible ? =3D)))</div><div><br></div><div><br></div><div>ps: if I add defau=
lt <b>null, </b>then all goes well:</div><div>=C2=A0</div><div>=C2=A0alter =
table tt add flag varchar2(50) =C2=A0default null not null ;</div><div>alte=
r table tt add flag varchar2(50) =C2=A0default null not null</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *</div><div>ERROR at line 1:</div><d=
iv>ORA-01758: table must be empty to add mandatory (NOT NULL) column=C2=A0<=
/div><div><div>=C2=A0</div><div>create table tt as select level id from dua=
l connect by level &lt;=3D100;</div><div>=C2=A0alter table tt add flag varc=
har2(50) =C2=A0default null not null ;</div><div>alter table tt add flag va=
rchar2(50) =C2=A0default null not null</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 *</div><div>ERROR at line 1:</div><div>ORA-01758: table m=
ust be empty to add mandatory (NOT NULL) column</div></div><div><br></div><=
div><br></div><div>ps: sorry for my English</div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-=
- <br><div class=3D"gmail_signature" data-smartmail=3D"gmail_signature">Too=
n Koppelaars<br>RuleGen BV<br>Toon.Koppelaars@RuleGen.com<br><a href=3D"htt=
p://www.RuleGen.com" target=3D"_blank">www.RuleGen.com</a><br><a href=3D"ht=
tp://TheHelsinkiDeclaration.blogspot.com" target=3D"_blank">TheHelsinkiDecl=
aration.blogspot.com</a><br><br>(co)Author: &quot;Applied Mathematics for D=
atabase Professionals&quot;<br><a href=3D"http://www.rulegen.com/am4dp-back=
cover-text" target=3D"_blank">www.rulegen.com/am4dp-backcover-text</a><br><=
/div>
</div>

--001a1145e1ca713172053e835da9--
--
http://www.freelists.org/webpage/oracle-l


