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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Constraints question

Re: Constraints question

From: Brian Peasland <peasland_at_edcmail.cr.usgs.gov>
Date: Thu, 23 Dec 1999 13:52:04 GMT
Message-ID: <38622904.AFB35C6C@edcmail.cr.usgs.gov>


The reason that line 6 is the error is because the NOT NULL constraint is a column constraint not a table constraint. When creating the table, you have to define the NOT NULL constraint when you define the column, not at the end of the create statement. Ex:

   CREATE TABLE t (id NUMBER CONSTRAINT id_nn NOT NULL); The Oracle DBA Test1 and Test2 Exam Cram by Michael Ault on page 83 says, "NOT NULL constraints can only be defined at the column level."

And I do believe that either line 4 is a type, or the comma should be removed from line 3.

HTH,
Brian

"Mark A. Framness" wrote:
>
> On Wed, 22 Dec 1999 20:59:29, Thomas Kyte <tkyte_at_us.oracle.com> wrote:
>
> > A copy of this was sent to Mark Framness <framnesso_at_my-deja.com>
> > (if that email address didn't require changing)
> > On Wed, 22 Dec 1999 20:01:03 GMT, you wrote:
> >
> > >Greetings All
> > >
> > >I am preparing for the SQL-PL/SQL OCP exam. One of the practice exams I
> > >have been working with has a question that I get right, but I don't know
> > >why it is right.
> > >
> > >The customer table is an existing table.
> > >CREATE TABLE sale
> > >(purchose_no NUMBER(9),
> > > customer_no NUMBER(9),
> > > CONSTRAINT sale_customer_id_fk REFERENCES customer(id),
> > > CONSTRAINT sale_purchase_no_pk PRIMARY KEY (purchase_no),
> > > CONSTRAINT sale_customer_no_nn NOT NULL (customer_no));
> > >
> > >The question is which line causes an error?
> > >
> >
> > line 4 (and when you fix that, line 6)
>
> Line 4 must be a typo. Because the exam clearly marks line 6 as the one in
> error.
>
> Anyway is it permitted to declare NOT NULL constraints like that? What is
> the problem if it is.
>
> I went in and changed it all so the NOT NULL constraint was defined on the
> line of the not null column and then it worked. Is that the problem? One
> would think that this would be mentioned in the OCP Prep book.
>
> From: Mark A. Framness
> http://netnet.net/~farmer/
> mframness_at_lakefield.net
>
> Go Pack Go!
> Oh balsam tree oh balsam tree I see you when I deer hunt!
> Brian Framness
Received on Thu Dec 23 1999 - 07:52:04 CST

Original text of this message

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