Re: [GENERAL] New To List - Mailing list pgsql-general

From Oliver Elphick
Subject Re: [GENERAL] New To List
Date
Msg-id 200001151009.KAA21853@linda.lfix.co.uk
Whole thread Raw
In response to New To List  (moebius@ip-solutions.net)
List pgsql-general
moebius@ip-solutions.net wrote:
  >   I do have a question though. I am trying to take a DB
  >written for MySql and convert the format of statements
  >over to Postgres for creation. I can't seem to find a
  >value 'blob' in PG. Is there something similar?? Also if

large objects may be what you want?

  >anyone can help me with this (see below). I can't figure
  >out how to make a primary, unique key. Here's the sql
  >file:
  >CREATE TABLE session (
  >   sid varchar(255) NOT NULL,
  >   val blob NOT NULL,
  >   changed varchar(14) NOT NULL,
  >   PRIMARY KEY (sid),
  >   UNIQUE sid_2 (sid)
  >);

CREATE TABLE session (
    sid varchar(255) PRIMARY KEY,

you don't need the UNIQUE constraint, since it is implicit in
PRIMARY KEY.  A unique constraint on a single field can be
expressed by

    field type UNIQUE

If a combination of fields is the primary key, you can use

CREATE TABLE foo (
    f1 TEXT NOT NULL,
    f2 TEXT NOT NULL,
    ...,
    PRIMARY KEY (f1,f2)
);
--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "For I know that my redeemer liveth, and that he shall
      stand at the latter day upon the earth"
                                       Job 19:25



pgsql-general by date:

Previous
From: admin
Date:
Subject: rules vs triggers
Next
From: Ed Loehr
Date:
Subject: Re: [GENERAL] keeping track of date