2011-09-13 6 views
0

私はPostgreSQL 7.4.19を使用しています。基本的なSQL文をINSERTとして使用できないのはなぜですか? は、私が(ブログ'Faster INSERT for Multiple Rows'から)オンライン例を実行している:私はそれを実行すると複数行の挿入に失敗する

create table things (things_id serial primary key, thing text); 
insert into things (thing) values ('thing nr. 0'), 
('thing nr. 1'), 
('thing nr. 2'), 
('thing nr. 3'); 

、それが得られます。私は間違って

ERROR: syntax error at or near "," 
LINE 1: insert into things (thing) values ('thing nr. 0'), 
                 ^

何をしているのですか?

+2

'psql'の中から' select version(); 'を実行するか' psql --version'を実行して、使用しているPostgreSQLのバージョンを確認してください。 –

+0

私のために働く。 ver 8.3 – Bohemian

+0

9.0と9.1で動作します。あなたが私たちに示していないものがなければなりません。 –

答えて

1

PostgreSQL 9.0で動作します。あなたのPostgreSQLのバージョンは?

 
skytf=> create table things (things_id serial primary key, thing text); 
NOTICE: CREATE TABLE will create implicit sequence "things_things_id_seq" for serial column "things.things_id" 

NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "things_pkey" for table "things" 
CREATE TABLE 
skytf=> \d things 
           Table "skytf.things" 
    Column | Type |       Modifiers       
-----------+---------+------------------------------------------------------------ 
things_id | integer | not null default nextval('things_things_id_seq'::regclass) 
thing  | text | 
Indexes: 
    "things_pkey" PRIMARY KEY, btree (things_id) 

skytf=> insert into things (thing) values ('thing nr. 0'), 
skytf-> ('thing nr. 1'), 
skytf-> ('thing nr. 2'), 
skytf-> ('thing nr. 3'); 
INSERT 0 4 

skytf=> select version(); 
                 version              
------------------------------------------------------------------------------------------------------------------- 
PostgreSQL 9.0.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48), 64-bit 
(1 row) 
関連する問題