Reputation: 5039
I'm new to Postgres and can't seem to edit the data in the table. The test box pops up but doesn't allow me to change the text. This initial table didn't have any PK or SERIAL. So I added them and my table definition is now this:
CREATE TABLE public.weather
(
city character varying(80) COLLATE pg_catalog."default",
temp_lo integer,
temp_hi integer,
prcp real,
date date,
id integer NOT NULL DEFAULT nextval('weather_id_seq'::regclass),
CONSTRAINT weather_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.weather
OWNER to postgres;
It's probably very simple
Upvotes: 48
Views: 63946
Reputation: 79
There are 2 ways to save updated data in PGAdmin:
Upvotes: 0
Reputation: 582
The above solutions all work for the specific case of the question, but I found that they did not work for me.
The reason is that my table did not have a primary key. As said on pgAdmin's official page:
To modify the content of a table, each row in the table must be uniquely identifiable. If the table definition does not include an OID or a primary key, the displayed data is read only.
I had believed that including:
CREATE TABLE IF NOT EXISTS public.mytable(
id INT GENERATED ALWAYS AS IDENTITY, [...]);
would automatically assign id as the primary key. I was wrong and thus could not edit "mytable" in pgAdmin.
Once I entered:
ALTER TABLE public.mytable
ADD CONSTRAINT mytable_pkey PRIMARY KEY (id);
The problem was solved.
Upvotes: 3
Reputation: 137
There is an image like Database with Save icon to save the edited data in the table
Upvotes: 4
Reputation: 24234
With pgadmin 4.6 the icon has changed (see screenshot):
a zoom to the icon:
You can also use the shortcut F6.
Upvotes: 22
Reputation: 3191
Right-click on your table, select View/Edit Data
-> All Rows
:
Then there is an icon in the top bar, looking like a table with an arrow pointing down (the icon on the right of the screenshot below):
The icon is gray but works nevertheless.
Upvotes: 10
Reputation: 8532
Right-click on your table, select View Data/View All Rows
(or one of the variants). That window will let you edit the data. Then press F6 to save changes (with thanks to leverglowh for pointing that out).
Upvotes: 113