M
M
MosVasil2018-08-09 20:09:50
PostgreSQL
MosVasil, 2018-08-09 20:09:50

How to clear a postgresql table column?

Is there an analogue of the truncate table command to clear a specific column/column in a table?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2018-08-09
@MosVasil

What does "clear column" mean? Removing all values ​​in it? Removing a column from a table?
ALTER TABLE "table" DROP COLUMN "column"

M
Melkij, 2018-08-09
@melkij

How do you imagine that? truncate throws out files and allocates empty ones. And for the column? This is not a columnar DBMS.
You can do this:

begin;
alter table tablename drop column foo;
alter table tablename add column foo ...
commit;

You can create a table through create table as select and then replace the old one with a new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question