简体   繁体   English

如何将PostgreSQL UNLOGGED功能应用于现有表?

[英]How to apply PostgreSQL UNLOGGED feature to an existing table?

我可以将现有表更改为UNLOGGED吗?

PostgreSQL 9.5+ allows setting an existing table as LOGGED / UNLOGGED with the ALTER TABLE command... detailed better here . PostgreSQL的9.5+允许设置一个现有的表并写入日志/与未注册的 ALTER TABLE命令的详细更好这里

For e.g. 
ALTER TABLE table_test SET LOGGED;
ALTER TABLE table_test SET UNLOGGED;

The following solution is for PostgreSQL versions<=9.4: 以下解决方案适用于PostgreSQL版本<= 9.4:

You can do: 你可以做:

create unlogged table your_table_alt as 
   select * from your_table;

Then: 然后:

drop table your_table;
alter table your_table_alt rename to your_table;

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

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