Обсуждение: New To List

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

New To List

От
moebius@ip-solutions.net
Дата:
Hello All,
   I'm not really sure how joining the list works but I
wanted to say hello. I am new to databases and also to
Postgres. Started reading the book up on the site. Very
helpful.
   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
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)
);

Again any help or pointers in the right direction is
greatly appreciated.
Kind regards,
Harry Hoffman
Product Systems Specialist
Restaurants Unlimited Inc.
(206) 634-3082 x. 270

Re: [GENERAL] New To List

От
"Oliver Elphick"
Дата:
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