Is it possible to make Postgresql database data visible or not, without erasing it?

Asked

Viewed 81 times

1

I have an application where in addition to registering and consulting clients, it allows to issue reports with customer information, the problem is that many of these customers already registered do not have more importance for current reports.

It is possible to make database data inaccessible without deleting them?

2 answers

3


You can do this in the application. You can create a column with a status to indicate that the row is disabled and does not show anywhere. Or you can use an existing column to specify this. Obviously, if you don’t have any data that can be used as a criterion to decide what to show or not, there is no way.

You can also make a view, but the accesses would have to access the view, access outside it, access the data you do not want (you can prohibit access outside it).

In theory you could use a conditional index (partial/filtered), but again, you would have to access it to consider the filter, so one way is that all indexes are like this.

Normally this should be planned in the solution as a whole. That is to say, has no automatic way to solve this.

I imagine you need to keep this data to ensure referential integrity, so any solution to move the data elsewhere doesn’t solve.

2

Would have some possible solutions:

  • Create a column to define whether the data is visible or not, then filter through that column.

  • Create a table with the ids of the records that should or should not be visible, and make a Join in that table or exists if it’s not too much data.

  • Create a "backup" table and move to it all the data you no longer want visible by removing it from the main table, but without deleting it. This would only work if there is no FK with another table, which does not allow deleting the records.

Are some ideas that can solve.

  • Thanks for the help, but actually I would like to know if Postgresql itself would possess a native way to hide DBA data wanted.

Browser other questions tagged

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