Re: [GENERAL] 9.6.1: INSERT with PK as serial

Поиск
Список
Период
Сортировка
От Rich Shepard
Тема Re: [GENERAL] 9.6.1: INSERT with PK as serial
Дата
Msg-id alpine.LNX.2.11.1701161620210.18553@localhost
обсуждение исходный текст
Ответ на Re: [GENERAL] 9.6.1: INSERT with PK as serial  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [GENERAL] 9.6.1: INSERT with PK as serial  (John R Pierce <pierce@hogranch.com>)
Re: [GENERAL] 9.6.1: INSERT with PK as serial  (David Rowley <david.rowley@2ndquadrant.com>)
Re: [GENERAL] 9.6.1: INSERT with PK as serial  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
On Mon, 16 Jan 2017, Tom Lane wrote:

> It looks like something deleted the quote marks.  How are you entering
> this SQL command, exactly?

Tom,

   I noticed that, too. Here's the first line:

INSERT INTO companies

('comp_id','comp_name','addr1','addr2','city','comp_state','postcode','country','phone','fax','e_mail','url','industry','status','comment')
VALUES
(1,'AG Spray Inc.',' ','PO Box

12129','Salem','OR','97309-0129','USA','503-371-7907','888-273-0937','info@agsprayinc.com','','Chemicals','Opportunity',''),

   Other than the comp_id PK column each column's data type is a delimited
string:

CREATE TABLE companies (
   comp_id serial PRIMARY KEY,
   comp_name varchar(64) NOT NULL,
   addr1 varchar(64),
   addr2 varchar(64),
   city varchar(16),
   comp_state char(2),
   postcode varchar(9),
   country varchar(12) DEFAULT 'USA' NOT NULL,
   phone varchar(10),
   fax varchar(10),
   e_mail varchar(64),
   url varchar(64),
   industry varchar(24) NOT NULL
     CONSTRAINT invalid_industry
     CHECK (industry in ('Agriculture', 'Business, other', 'Chemicals',
     'Energy', 'Law', 'Manufacturing', 'Mining', 'Municipalities',
     'Ports/Marine Services', 'Transportation')),
   status varchar(20) NOT NULL
     CONSTRAINT invalid_status
     CHECK (status in ('Client', 'Proposal submitted', 'Prospect',
     'Referral', 'Opportunity', 'No further contact')),
   comment text
);

> Also, you can't just write double commas to leave out a item in the
> value list.  You could write DEFAULT there, ie

   I tried with ,, and ,'', and ,' '. Same error each time. Also, listing
each column name does not fix the problem.

Thanks,

Rich


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] 9.6.1: INSERT with PK as serial
Следующее
От: John R Pierce
Дата:
Сообщение: Re: [GENERAL] 9.6.1: INSERT with PK as serial