Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Table creation problem

Re: Table creation problem

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Wed, 09 Oct 2002 20:40:25 GMT
Message-ID: <3DA49417.2F1375B7@exesolutions.com>


gamaz wrote:

> Thanks Simon, I apprciate it. Now I see where I have gone wrong.
> "S2" <email_at_mail.com> wrote in message news:3DA48542.50602_at_mail.com...
> > gamaz wrote:
> > > Hi,
> > > I am trying to create a table where I want only the first two fields to
> be
> > > not null values(composite primary key). However, the third row which has
> a
> > > datatype 'number' is automatically getting NOT NULL constraint inspite
> of
> > > forcing null constraint in the table definition. Is there any way to
> stop
> > > this from happening?
> > > Thanks in advance.
> > >
> > > The script I am running is the following:
> > >
> > > SQL> create table stock_price (
> > > 2 SYMBOL VARCHAR2(5) NOT NULL,
> > > 3 CLOSE_DATE DATE NOT NULL,
> > > 4 SEQ_NO NUMBER NULL,
> > > 5 OPEN NUMBER(8,4),
> > > 6 HI NUMBER(8,4),
> > > 7 LO NUMBER(8,4),
> > > 8 CLOSE NUMBER(8,4),
> > > 9 VOLUME NUMBER(12),
> > > 10 CONSTRAINT STOCK_PK PRIMARY KEY(SYMBOL, SEQ_NO)
> > > 11 );
> >
> > if SEQ_NO is primary key, it becomes automatically not null.
> > use
> > CONSTRAINT STOCK_PK PRIMARY KEY(SYMBOL, CLOSE_DATE
> > instead of
> > CONSTRAINT STOCK_PK PRIMARY KEY(SYMBOL, SEQ_NO
> >
> > --
> >
> > regards,
> > Simon
> >
> >

Also ... a NOT NULL constraint on a primary key column is just a waste of perfectly good CPU. The primary key constraint, by itself, enforces the not null condition.

Daniel Morgan Received on Wed Oct 09 2002 - 15:40:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US