Обсуждение: check constriaint for BLOB

Поиск
Список
Период
Сортировка

check constriaint for BLOB

От
"news.postgresql.org"
Дата:
Is it possible to add a constraint during "CREATE TABLE" that guarantees
objects in a certain field will be greater than zero size?

Thanks,

Howie



Re: check constriaint for BLOB

От
"Aasmund Midttun Godal"
Дата:
CREATE TABLE testus (
    data BYTEA CHECK (octet_length(data) > 10000)
);
Perhaps?

Regards,

Aasmund.

On Mon, 26 Nov 2001 15:36:28 -0800, "news.postgresql.org" <howieshouse@home.com> wrote:
> Is it possible to add a constraint during "CREATE TABLE" that guarantees
> objects in a certain field will be greater than zero size?
>
> Thanks,
>
> Howie
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46

Re: check constriaint for BLOB

От
"Howard Williams"
Дата:
Thanks for the response, but...

I'm using data type oid - as far as I know, that's not the same thing as
byteA.  Please correct me if I'm wrong.

Howie

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Aasmund Midttun
Godal
Sent: Monday, November 26, 2001 5:02 PM
To: howieshouse@home.com
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] check constriaint for BLOB


CREATE TABLE testus (
    data BYTEA CHECK (octet_length(data) > 10000)
);
Perhaps?

Regards,

Aasmund.

On Mon, 26 Nov 2001 15:36:28 -0800, "news.postgresql.org"
<howieshouse@home.com> wrote:
> Is it possible to add a constraint during "CREATE TABLE" that guarantees
> objects in a certain field will be greater than zero size?
>
> Thanks,
>
> Howie
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


Re: check constriaint for BLOB

От
"Aasmund Midttun Godal"
Дата:
CREATE FUNCTION lo_size (OID) RETURNS NUMERIC AS 'SELECT   sum(octet_length(data)) FROM pg_largeobject WHERE loid = $1
GROUPBY (loid)' LANGUAGE 'sql'; 

Yes you can use largeobject - then you would something along the line of

CREATE TABLE byteaisbetter (
    loid OID CHECK (lo_size(loid) > 1000000)
);

But bytea is better....

Regards,

Aasmund.

On Mon, 26 Nov 2001 18:22:49 -0800, "Howard Williams" <howieshouse@home.com> wrote:
> Thanks for the response, but...
>
> I'm using data type oid - as far as I know, that's not the same thing as
> byteA.  Please correct me if I'm wrong.
>
> Howie
>
> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Aasmund Midttun
> Godal
> Sent: Monday, November 26, 2001 5:02 PM
> To: howieshouse@home.com
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] check constriaint for BLOB
>
>
> CREATE TABLE testus (
>     data BYTEA CHECK (octet_length(data) > 10000)
> );
> Perhaps?
>
> Regards,
>
> Aasmund.
>
> On Mon, 26 Nov 2001 15:36:28 -0800, "news.postgresql.org"
> <howieshouse@home.com> wrote:
>
> Aasmund Midttun Godal
>
> aasmund@godal.com - http://www.godal.com/
> +47 40 45 20 46
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>

Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46