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: limit TABLE to only one record

Re: limit TABLE to only one record

From: sriram717 <sriram.vrinda_at_googlemail.com>
Date: Thu, 15 Nov 2007 07:04:47 -0800 (PST)
Message-ID: <e8f9266c-b090-451a-94db-17c55081fe38@b36g2000hsa.googlegroups.com>


On Nov 15, 2:57 pm, Brian Tkatch <N/A> wrote:
> On Thu, 15 Nov 2007 08:54:38 -0500, Brian Tkatch <N/A> wrote:
> >On Wed, 14 Nov 2007 13:19:39 -0800, "fitzjarr..._at_cox.net"
> ><fitzjarr..._at_cox.net> wrote:
>
> <SNIP>
> >>SQL> CREATE TABLE One_Record_Only
> >> 2 (
> >> 3 Id INT DEFAULT 1,
> >> 4 Data INT,
> >> 5 CONSTRAINT ORO1_Id_CK CHECK(Id = 1),
> >> 6 CONSTRAINT ORO1_Id_PK PRIMARY KEY(Id)
> >> 7 USING INDEX TABLESPACE INDX
> >> 8 );
>
> <SNIP>
> >>David Fitzjarrell
>
> <SNIP>
>
> OK, i see, i did not realize Oracle named the PK INDEX withe the same
> name as the CONSTRAINT. I remember using USING INDEX, but i must have
> used it for choosing the TABLESPACEs, and not for naming.
>
> I don't understand the NOT NULL issue though. The documentation
> states:
>
> Oracle enforces all PRIMARY KEY constraints using indexes. In Figure
> 21-5, the primary key constraint created for the department_id column
> is enforced by the implicit creation of:
>
> * A unique index on that column
> * A NOT NULL constraint for that column
>
> So, I tried an example:
>
> SQL>CREATE TABLE A(A INT CONSTRAINT A PRIMARY KEY);
>
> Table created.
>
> SQL>SELECT
> 2 Constraint_Type,
> 3 Constraint_Name
> 4 FROM
> 5 DBA_Constraints
> 6 WHERE
> 7 Table_Name = 'A';
>
> C CONSTRAINT_NAME
> - ------------------------------
> P A
>
> Where is the NOT NULL CONSTRAINT?
>
> B.- Hide quoted text -
>
> - Show quoted text -

How about

TEST>desc a

 Name                                      Null?    Type
 ----------------------------------------- --------
---------------------------

 A                                         NOT NULL NUMBER(38)

a PRIMARY Key is a Primary key.

Thanks

www.ramsora.blogspot.com Received on Thu Nov 15 2007 - 09:04:47 CST

Original text of this message

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