Skip to content
Advertisement

How to “hide” a row in Oracle SQL database but not delete it

Is there a way to “hide” a row in Oracle SQL database without deleting it, So that it is still in the database but does not show up on the webpage as a search result?

For example, I want to hide a specific city in my database from being displayed in the results when searching for cities on the webpage.

Advertisement

Answer

Add a column to the table with a flag as to whether to show or hide the row and then add a WHERE filter to your query to filter out rows where the row should be hidden.

If you have the table:

Then you can do something like:

(Note: INVISIBLE will cause a column not to be shown when you use SELECT * FROM cities, it can still be shown if you name the columns SELECT name, visibility FROM cities.)

Then set a row to not be visible:

Then:

Outputs:

NAME
Berlin
Lisbon
Prague
Kiev

db<>fiddle here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement