Re: limit TABLE to only one record



On Nov 14, 12:55 pm, Brian Tkatch <N/A> wrote:
I am looking to store an easily modifiable value that a VIEW can use,
without issuing any DDL statements. I'm guessing that a TABLE with one
record would be a good way. The question then is how to limit a TABLE
to only one record:

CREATE TABLE One_Record_Only
(
Id INT DEFAULT 1,
Data INT,
CONSTRAINT ORO1_Id_NN CHECK(Id IS NOT NULL),
CONSTRAINT ORO1_Id_CK CHECK(Id = 1),
CONSTRAINT ORO1_Id_PK PRIMARY KEY(Id)
USING INDEX (CREATE UNIQUE INDEX ORO1_Id_PK ON One_Record_Only(Id))
);

Is there a more straightforward emthod to limit a TABLE to only one
record?

Is there another way to accomplish the same goal?

B.

Your syntax, as mentioned earlier, is wrong. It should be:

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 );

Table created.

SQL>
SQL> Insert into one_record_only (data)
2 values (1);

1 row created.

SQL>
SQL> insert into one_record_only (data)
2 values (2);
insert into one_record_only (data)
*
ERROR at line 1:
ORA-00001: unique constraint (BING.ORO1_ID_PK) violated


SQL> insert into one_record_only (id,data)
2 values (2,2);
insert into one_record_only (id,data)
*
ERROR at line 1:
ORA-02290: check constraint (BING.ORO1_ID_CK) violated


SQL>



David Fitzjarrell

.



Relevant Pages

  • Re: SQL
    ... Even SQL cannot avoid them. ... If you add X with one constraint to Y with other constraint and what would ... RDBMS exist only because in 70s there were no languages capable to provide ... There is no numeric type for all purposes. ...
    (comp.object)
  • Re: SQL
    ... SQL is more or less based on "COBOL thinking". ... possible nor most type-free that a relational query language can be. ... If you add X with one constraint to Y with other constraint and what would ... A relational interface fits to a kd-tree as a beach umbrella does ...
    (comp.object)
  • Re: Parameter??
    ... in common with most available SQL ... given month' Validation Rule or constraint? ... date_col DATETIME NOT NULL, ... The above relies on the Jet implementation to coerce a DATETIME to ...
    (microsoft.public.access.queries)
  • Re: dropping a relationship (i.e. constraint?)
    ... so they may have been something in that SQL statement that JET was not ... ignorant of constraint names until last week. ... CONSTRAINT PrimaryKey PRIMARY KEY (RName) ...
    (microsoft.public.access.queries)
  • Re: How do you mulitply in a field?
    ... asked how one places a unique constraint on a combination of fields ... This will work for Jet in ANSI-92 Query Mode Jet SQL. ... I apply security so that the database can't be hacked. ... If I am selecting only one name, ...
    (microsoft.public.access.tablesdbdesign)