如何使用 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
How to ALTER a table in PostgreSQL database using pgAdmin III
提问by vnnogile
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?
在 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 中,您基本上有两个选项来更改表结构:
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.
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.
在左侧的层次结构中,导航到表并使用上下文菜单(用鼠标右键单击)访问表的属性。在弹出对话框中,您可以进行更改。您还可以在层次结构中深入查看各个列,并对列名称、数据类型、列约束等进行更改。
连接到数据库后,您会在顶部按钮栏中看到一个 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 不会刷新屏幕左侧的树层次结构,您必须手动执行此操作。右键单击一个节点,然后单击“刷新”以更新该节点中的信息以及该节点下的所有内容。(因此,如果您对单个表进行了更改,请单击表名,如果多个表受到影响,请单击模式名称等)