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: SQL*Plus - PK Question

Re: SQL*Plus - PK Question

From: Daniel Morgan <damorgan_at_exesolutions.com>
Date: Tue, 23 Apr 2002 15:40:40 GMT
Message-ID: <3CC58068.9FC53883@exesolutions.com>


Sted Alana wrote:

> I have come across many examples in sql*plus with regards to using 'not
> nulls' in conjunction with primarys keys. This bothers me because from my
> reading when a primary key is defined for an attributes(s) of a table, it
> assumes that those values cannot contain null values, but yet i see this:
>
> create table Example
> (
> sid char(5) not null,
> ....
> constraint pk_sid primary key (sid)
> );
>
> why need to use not null when primary key implicitly imposes that contraint?
>
> Any help appreciated.

Part of the problem is bad developers ... but part of it is bad tools.

I have seen plenty of DDL written as follows:

CREATE TABLE xyz (

   pk_field NUMBER(10) NOT NULL,
  morefield ....);

ALTER TABLE
ADD CONSTRAINT pk_xyz PRIMARY KEY ...

But sometime it reverse engineering code with products like TOAD, SQL Navigator, ERWin, Visio, (I haven't checked them all so don't feel compelled to correct me) will produce a build script that does this. I have even seen cases where they build the index for the primary key as a separate item rather than just creating the constraint. So that if someone does a bit of cut and paste they may build the constraint first, then try to build the index, and generate an error.

Daniel Morgan Received on Tue Apr 23 2002 - 10:40:40 CDT

Original text of this message

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