| From: | Richard Broersma <richard(dot)broersma(at)gmail(dot)com> |
|---|---|
| To: | Brandon Metcalf <brandon(at)geronimoalloys(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: limit table to one row |
| Date: | 2009-06-04 20:30:29 |
| Message-ID: | 396486430906041330n18921c62s9f094c58c00ea7be@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, Jun 4, 2009 at 1:23 PM, Brandon Metcalf
<brandon(at)geronimoalloys(dot)com> wrote:
> Got it. Currently, it doesn't have a column for an ID, but I can add
> one if this is the only way.
Actually any column with a unique index on it will work. It doesn't
have to be primary key or even a serial id.
ANSI-SQL 92 allows for the following syntax:
CONSTRAINT Only_one_row
CHECK( 1 >= (SELECT COUNT(*) FROM _this_table;));
However, I have yet to find a RDBMS (PostgreSQL included) that
supports select statements in a table's check constraint.
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Brandon Metcalf | 2009-06-04 20:35:27 | Re: limit table to one row |
| Previous Message | Brandon Metcalf | 2009-06-04 20:23:28 | Re: limit table to one row |