2016-08-22 85 views
0

我有以下表定义:插入一行到PostgreSQL表

foo=# \d+ tag 
                 Table "public.tag" 
    Column |   Type   |     Modifiers      | Storage | Stats target | Description 
-------------+------------------------+--------------------------------------------------+----------+--------------+------------- 
id   | integer    | not null default nextval('tag_id_seq'::regclass) | plain |    | 
name  | character varying(255) | not null           | extended |    | 
version  | integer    | not null           | plain |    | 
description | character varying(255) | not null           | extended |    | 
active  | boolean    | not null           | plain |    | 
Indexes: 
    "tag_pkey" PRIMARY KEY, btree (id) 
    "unique_tag" UNIQUE CONSTRAINT, btree (name, version) 

我试图将行插入如下:

foo=# insert into tag (name, version, description, active) values ("scala", 1, "programming language", true); 
ERROR: column "scala" does not exist 
LINE 1: ... tag (name, version, description, active) values ("scala", 1... 

我从手册,但它把这个命令不起作用。我做错了什么?这是一件简单的事情,但我很难过。我第一次使用postgres。

+0

在文字中使用单引号。 – klin

回答

1

Postgres使用单引号。

insert into tag (name, version, description, active) values ('scala', 1, 'programming language', true); 
+0

dammit postgres! –

+1

@ Mika'il与postgres的关系较少,更多与ansi sql有关... – donkopotamus