On 2009-06-09, Grzegorz Jaśkiewicz wrote:
> 2009/6/9 Brandon Metcalf :
>
>
>> I'm not sure I follow how this solves the problem.
>
> Well, surely if you just need one row, you need single value per key.
> And that's the, imo , better solution to that problem, than limiting
> number of rows.
not r
On Tue, 09 Jun 2009 08:24:01 -0700, Brandon Metcalf
wrote:
CREATE TABLE foo (
start DATE,
length VARCHAR(10),
);
I need to be able to get one value for each column at any given time.
CREATE UNIQUE INDEX u ON foo ((start IS NOT NULL));
You would just make sure you SELECT FROM f
g == gryz...@gmail.com writes:
g> If you want to store period of time, why store it as varchar ?
g> just store two rows
g> create table foo(
g> n varchar,
g> val date
g> );
g> and store two rows:
g> "start", now(),
g> "end", now()+'something '::interval
g> Wouldn't that do, or is
2009/6/9 Brandon Metcalf :
>
> CREATE TABLE foo (
> start DATE,
> length VARCHAR(10),
> );
>
> I need to be able to get one value for each column at any given time.
> Specifically, I need to get a value for start and add the value for
> length to get a time period. Since your approach wo
g == gryz...@gmail.com writes:
g> 2009/6/9 Brandon Metcalf :
g> > I'm not sure I follow how this solves the problem.
g> Well, surely if you just need one row, you need single value per key.
g> And that's the, imo , better solution to that problem, than limiting
g> number of rows.
Hm. Ma
2009/6/9 Brandon Metcalf :
> I'm not sure I follow how this solves the problem.
Well, surely if you just need one row, you need single value per key.
And that's the, imo , better solution to that problem, than limiting
number of rows.
--
GJ
--
Sent via pgsql-general mailing list (pgsql-gene
g == gryz...@gmail.com writes:
g> just change whatever you are storing to be in vertical structure,
g> instead of horizontal. so instead of create table foo(a int, b int, c
g> int, etc), try:
g> create table foo(name varchar, val int);
g> common mistake I've seen committed by people..
I'm
On 2009-06-04, Brandon Metcalf wrote:
> Is there a way when creating a table to limit it to one row? That is,
> without using a stored procedure?
>
> I searched the documentation, but didn't find anything.
create a unique index, and a constraint to a single value on one of
the columns :)
--
S
On Sun, Jun 7, 2009 at 1:38 AM, Craig Ringer wrote:
> Brandon Metcalf wrote:
>> Is there a way when creating a table to limit it to one row? That is,
>> without using a stored procedure?
>>
>> I searched the documentation, but didn't find anything.
>>
>
>
> CREATE TABLE x (...);
>
> CREATE UNIQUE
Brandon Metcalf wrote:
> Is there a way when creating a table to limit it to one row? That is,
> without using a stored procedure?
>
> I searched the documentation, but didn't find anything.
>
CREATE TABLE x (...);
CREATE UNIQUE INDEX x_only_one_row ON ((1));
--
Craig Ringer
--
Sent via pg
On Saturday 6. June 2009, Grzegorz Jaśkiewicz wrote:
>just change whatever you are storing to be in vertical structure,
>instead of horizontal. so instead of create table foo(a int, b int, c
>int, etc), try:
>
>create table foo(name varchar, val int);
>
>common mistake I've seen committed by people
Merlin Moncure writes:
> On Sat, Jun 6, 2009 at 2:07 PM, Tom Lane wrote:
>> If you're willing to use a trigger, just insert the one allowed row
>> and then install a trigger that throws error for any insert or delete
>> attempt ...
> what if you need to delete then insert? :-)
Hmm ... I supposed
On Sat, Jun 6, 2009 at 2:07 PM, Tom Lane wrote:
> Merlin Moncure writes:
>> On Thu, Jun 4, 2009 at 4:13 PM, Brandon
>> Metcalf wrote:
>>> Is there a way when creating a table to limit it to one row? That is,
>>> without using a stored procedure?
>
>> you can also do it with a trigger.
>
> If you'
Merlin Moncure writes:
> On Thu, Jun 4, 2009 at 4:13 PM, Brandon
> Metcalf wrote:
>> Is there a way when creating a table to limit it to one row? That is,
>> without using a stored procedure?
> you can also do it with a trigger.
If you're willing to use a trigger, just insert the one allowed ro
On Thu, Jun 4, 2009 at 4:13 PM, Brandon
Metcalf wrote:
> Is there a way when creating a table to limit it to one row? That is,
> without using a stored procedure?
>
> I searched the documentation, but didn't find anything.
>
> --
you can also do it with a trigger.
create or replace function one_
just change whatever you are storing to be in vertical structure,
instead of horizontal. so instead of create table foo(a int, b int, c
int, etc), try:
create table foo(name varchar, val int);
common mistake I've seen committed by people..
--
Sent via pgsql-general mailing list (pgsql-general@p
p == pgmaili...@codecraft.se writes:
p> On 4 jun 2009, at 22.17, Richard Broersma wrote:
p> > On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
p> > wrote:
p> >> Is there a way when creating a table to limit it to one row? That
p> >> is,
p> >> without using a stored procedure?
p> >
p> >
On 4 jun 2009, at 22.17, Richard Broersma wrote:
On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
wrote:
Is there a way when creating a table to limit it to one row? That
is,
without using a stored procedure?
Sure just add a check constraint along the lines of:
CONSTRAINT Only_one_row
r == richard.broer...@gmail.com writes:
r> On Thu, Jun 4, 2009 at 1:23 PM, Brandon Metcalf
r> wrote:
r> > Got it. ?Currently, it doesn't have a column for an ID, but I can add
r> > one if this is the only way.
r> Actually any column with a unique index on it will work. It doesn't
r> hav
On Thu, Jun 4, 2009 at 1:23 PM, Brandon Metcalf
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
r == richard.broer...@gmail.com writes:
r> On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
r> wrote:
r> > Is there a way when creating a table to limit it to one row? ?That is,
r> > without using a stored procedure?
r> Sure just add a check constraint along the lines of:
r> CONSTRAINT On
On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
wrote:
> Is there a way when creating a table to limit it to one row? That is,
> without using a stored procedure?
Sure just add a check constraint along the lines of:
CONSTRAINT Only_one_row
CHECK( tableuniqueid = 1 ); --assuming you row has
On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
wrote:
> Is there a way when creating a table to limit it to one row? That is,
> without using a stored procedure?
Sure just add a check constraint along the lines of:
CONSTRAINT Only_one_row
CHECK( tableuniqueid = 1 ); --assuming you row has
Is there a way when creating a table to limit it to one row? That is,
without using a stored procedure?
I searched the documentation, but didn't find anything.
--
Brandon
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.pos
24 matches
Mail list logo