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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29960872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:53:37  来源:igfitidea点击:

How to ALTER a table in PostgreSQL database using pgAdmin III

postgresqlpgadmin

提问by vnnogile

In a MySQL database I can change a table structure with an ALTERstatement 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 ALTERthe table in the PostgreSQL database using pgAdmin III?

在 MySQL 数据库中,我可以使用ALTER语句更改表结构,但如何使用 pgAdmin III 在 PostgreSQL 中执行此操作?每次我删除表并再次运行该表的更新创建查询时,在 pgAdmin III 中。是否可以ALTER使用 pgAdmin III 访问 PostgreSQL 数据库中的表?

回答by Patrick

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. Clicking that opens up a SQL console and you can type in an ALTERstatement using standard SQL syntax.

  1. 在左侧的层次结构中,导航到表并使用上下文菜单(用鼠标右键单击)访问表的属性。在弹出对话框中,您可以进行更改。您还可以在层次结构中深入查看各个列,并对列名称、数据类型、列约束等进行更改。

  2. 连接到数据库后,您会在顶部按钮栏中看到一个 SQL 按钮。单击它会打开一个 SQL 控制台,您可以ALTER使用标准 SQL 语法输入一条语句。

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

请注意,通过 SQL 控制台进行更改后,pgAdmin III 不会刷新屏幕左侧的树层次结构,您必须手动执行此操作。右键单击一个节点,然后单击“刷新”以更新该节点中的信息以及该节点下的所有内容。(因此,如果您对单个表进行了更改,请单击表名,如果多个表受到影响,请单击模式名称等)

回答by Parth Patel

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

服务器 -> 数据库 -> 架构 -> 表 -> 右键单击​​表 -> 属性...

Step1 :

步骤1 :

Step1

步骤1

Step2 :

第2步 :

Step2

第2步

Step3 :

步骤3:

Step3

Step3

Last step is Saveyour changes...

最后一步是保存您的更改...