简体   繁体   English

如何使用pgAdmin III在PostgreSQL数据库中更改表

[英]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? 在MySQL数据库中,我可以使用ALTER语句更改表结构,但是如何在PostgreSQL中使用pgAdmin III做到这一点? In pgAdmin III every time I drop the table and again run the updated create query of that table. 每次删除表并再次运行该表的更新的create查询时,在pgAdmin III中。 Is is possible to ALTER the table in the PostgreSQL database using pgAdmin III? 是否可以使用pgAdmin III ALTER PostgreSQL数据库中的表?

In pgAdmin III you basically have two options to alter a table structure: 在pgAdmin III中,您基本上有两个选项可以更改表结构:

  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. 连接到数据库后,您会在顶部按钮栏中看到一个SQL按钮。 Clicking that opens up a SQL console and you can type in an ALTER statement using standard SQL syntax. 单击可打开SQL控制台,您可以使用标准SQL语法键入ALTER语句。

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. 请注意,在通过SQL控制台进行更改后,pgAdmin III不会刷新屏幕左侧的树层次结构,您必须手动执行此操作。 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.) (因此,如果您对单个表进行了更改,请在表名上单击鼠标右键,如果多个表受到影响,请在模式名称上单击鼠标右键,等等。)

Server -> Database -> Schema -> Table -> Right Click On Table -> Properties... 服务器->数据库->模式->表->右键单击表->属性...

Step1 : 第1步 :

第1步

Step2 : 第2步 :

第2步

Step3 : 第三步:

第三步:

Last step is Save your changes... 最后一步是保存您的更改...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM