Update to clear entire column

Asked

Viewed 10,071 times

3

I need to make a update in the database in which zero 30 thousand records, however I need to reset only the record of one of the columns.

Example table: cd_product|ds_product|pr_product|dt_update

This table contains the 30thousand records and I need to reset all the dt_atualizacao, but only her, the other columns cannot be changed.

How can I ride this update?

  • Is there anything you are not saying? I ask this because it is something extraordinarily trivial to do this. What kind of column is this? DATE? You want it to be void or what value?

  • The reason is that there is a new routine that reads this table and for each row without the dt_update a new cd_group information will be inserted. The routine is already ready and now I just need to clean all the dt_updates for the routine to work. The column is type DATETIME and I need it to be empty.

  • What is zero? What value should be?

  • Pardon the confusion, it’s to be null.

2 answers

6


It would be quite trivial to annul if possible and desirable:

UPDATE tabela SET dt_atualizacao = null;

Or put a very low value:

UPDATE tabela SET dt_atualizacao = TO_DATE('0000-01-01 00:00:00', 'yyyy/mm/dd hh24:mi:ss');

I put in the Github for future reference.

  • I didn’t think it was that simple, thank you !

2

UPDATE TABELA SET DT_ATUALIZACAO = NULL

But watch out:

1) There are triggers in this table , the update generates some demand on account of this operation ? Log etc

2) There is room for track Audit of the Bank?

The doubt "scares" because it is a trivial operation as @Maniero said and may mask some other problem.

  • I understand that it could be trivial and even dangerous for an operation like this. I am only doing it so that the new information requested by the client is inserted through the new routine that looks at the empty dt_update. Thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.