Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert row into a postgresql table

Tags:

postgresql

I have the following table definition:

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)

I am trying to insert a row into as follows:

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...

I took this command from the manual but it doesn't work. What I am doing wrong? It's a simple thing but I'm stumped. First time I am using postgres.


1 Answers

Postgres uses single quotes.

insert into tag (name, version, description, active) values ('scala', 1, 'programming language', true);
like image 200
Hexy Avatar answered Sep 21 '25 14:09

Hexy