Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ALTER a table in PostgreSQL database using pgAdmin III

In a MySQL database I can change a table structure with an ALTER statement but how to do that in PostgreSQL with pgAdmin III? In pgAdmin III every time I drop the table and again run the updated create query of that table. Is is possible to ALTER the table in the PostgreSQL database using pgAdmin III?

like image 400
vnnogile Avatar asked Apr 30 '15 06:04

vnnogile


2 Answers

Server -> Database -> Schema -> Table -> Right Click On Table -> Properties...

Step1 :

Step1

Step2 :

Step2

Step3 :

Step3

Last step is Save your changes...

like image 73
Parth Patel Avatar answered Oct 17 '22 07:10

Parth Patel


In pgAdmin III you basically have two options to alter a table structure:

  1. In the hierarchy to the left, navigate to the table and use the context menu (right-click with the mouse) to access the properties of the table. In the pop-up dialog you can make the changes. You can also drill down in the hierarchy to the individual columns and make changes to column names, data types, column constraints, etc.

  2. After you connect to the database, you see a SQL button in the top button bar. Clicking that opens up a SQL console and you can type in an ALTER statement using standard SQL syntax.

Note that pgAdmin III does not refresh the tree hierarchy on the left of the screen after making changes through the SQL console, you have to do that manually. Right click on a node and click "Refresh" to update the information in that node and everything under that node. (So if you made changes to a single table, r-click on the table name, if multiple tables are affected r-click on the schema name, etc.)

like image 38
Patrick Avatar answered Oct 17 '22 08:10

Patrick