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: Question on creation of a table

Re: Question on creation of a table

From: Roy Smith <roy_at_popmail.med.nyu.edu>
Date: Wed, 20 Jan 1999 11:13:36 -0500
Message-ID: <roy-2001991113360001@qwerky.med.nyu.edu>


arunal_at_hotmail.com wrote:
> Hi all, I want to create a table with only one record. While creating the
> table using create table command itself i want to include some
> condition/constraint which restricts the table to contain only one row.

There may be neater ways to do it, but this should work:

create table foo (

        my_data         varchar2(10),
        x               number  constraint x1 unique
                                constraint x2 not null
                                constraint x3 check (x = 1)
);

The three column constraints on x combine to ensure that there can never be more than a single row. The above code will allow zero rows, but I'm assuming you're really worried about somebody adding additional rows.

The only annoying thing here is that you must supply an extra column value for x, but if that's a problem, I suppose you could build some kind of view to hide that too.

--
Roy Smith <roy_at_popmail.med.nyu.edu>
New York University School of Medicine Received on Wed Jan 20 1999 - 10:13:36 CST

Original text of this message

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