How to insert a row in postgreSQL pgAdmin?

Postgresql

Postgresql Problem Overview


I am new to postgreSQL. Is there any way to insert row in postgreSQL pgAdmin without using SQL Editor (SQL query)?

Postgresql Solutions


Solution 1 - Postgresql

The accepted answer is related to PgAdmin 3 which is outdated and not supported. For PgAdmin 4 and above, the application is running in the browser.

After you create your table, you have to make sure that your table has a primary key otherwise you couldn't edit the data as mentioned in the official documentation.

> 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. Note that views > cannot be edited; updatable views (using rules) are not supported.

1- Add primary key

Expand your table properties by clicking on it in the pgAdmin4 legend. Right-click on 'Constraints', select 'Create' --> 'Primary Key'to define a primary key column.

enter image description here

2- View the data in excel like format

Browser view, right-click on your table --> select View/Edit Data --> All Rows enter image description here

3- Add new row / Edit data

On the Data Output tab at the bottom of the table below the last row, there will be an empty row where you can enter new data in an excel-like manner. If you want to make updates you can also double click on any cell and change its value.

enter image description here

4- Save the changes

Click on the 'Save' button on the menu bar near the top of the data window. enter image description here

Solution 2 - Postgresql

I think some answers don't provide an answer to the original question, some of them insert records but with SQL statements and the OP clearly said WITHOUT, so I post the right answer: (Step by Step) enter image description here enter image description here

enter image description here

enter image description here

Solution 3 - Postgresql

enter image description here

Alternatively you can use the query tool:

INSERT INTO public.table01( name, age) VALUES (?, ?);

use the lightning icon to execute.

Solution 4 - Postgresql

You can do that without the SQL editor, but it's better to do this by queries.

Although, in pgAdmin, there is an option which you can click to have an excel-like window where you can add and update data in a table without using SQL language. Please select a table which you want to add a row first and click on the next icon here below.

enter image description here

Solution 5 - Postgresql

Editing table data without primary key is forbidden
If your tables don't have a primary key or OIDs, you can view the data only.
Inserting new rows and changing existing rows isn't possible for the Edit Data tool without primary key.

Solution 6 - Postgresql

Use INSERT:

INSERT INTO tablename (field1, field2) values ('value1', 2);

Solution 7 - Postgresql

All the above are correct answers. I just want to add that : When u create a table, make sure u have atleast one column as PRIMARY_KEY. Then, just follow the GUI : View/Edit data. U can add row as the last row of the table

Solution 8 - Postgresql

on pgAdmin 4, right-click on the table and use the item like below. You can also use that script in the background.

enter image description here

Finally, to watch the inserted data do like below. You can also use that script in the background.

enter image description here

Solution 9 - Postgresql

As an update, the icon for the save button is different in pgAdmin 4.

This is how the menu should look after right-clicking on the table you want to insert into and hovering over "View/Edit Data".

enter image description here

After adding rows, either press F6 (on Ubuntu) or click the icon that looks like a stack of discs (database icon) with a lock on it.

Zoomed in:


enter image description here


Wide View:


enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIlaView Question on Stackoverflow
Solution 1 - Postgresqlcm1View Answer on Stackoverflow
Solution 2 - PostgresqlGödel77View Answer on Stackoverflow
Solution 3 - PostgresqlRutger HofsteView Answer on Stackoverflow
Solution 4 - PostgresqlKarelGView Answer on Stackoverflow
Solution 5 - PostgresqlniaomingjianView Answer on Stackoverflow
Solution 6 - Postgresqluser1907906View Answer on Stackoverflow
Solution 7 - PostgresqlxenowitsView Answer on Stackoverflow
Solution 8 - PostgresqlOmiD_DView Answer on Stackoverflow
Solution 9 - PostgresqlJoachim RivesView Answer on Stackoverflow