Deleting entire data from a particular column in oracle-sql
Solution 1
The DELETE statement removes entire rows of data from a specified table or view
If you want to "remove" data from particular column update it:
UPDATE table_name
SET your_column_name = NULL;
or if column is NOT NULL
UPDATE table_name
SET your_column_name = <value_indicating_removed_data>;
You can also remove entire column using DDL:
ALTER TABLE table_name DROP COLUMN column_name;
Solution 2
Use Invisible Type, which is from an oracle 12cR2.
ALTER TABLE LOG1
MODIFY operation INVISIBLE
It is a better than drop of a particular column.If you need to visible you can get back by altering with an VISIBLE
of a column name.
Solution 3
In SQL, delete
deletes rows not columns.
You have three options in Oracle:
- Set all the values to
NULL
using update. - Remove the column from the table.
- Set the column to unused.
The last two use alter table
:
alter table t drop column col;
alter table t set unused (col);
Rajeev
Updated on July 31, 2022Comments
-
Rajeev over 1 year
Recently I have started learning
Oracle-sql
. I know that with the help ofDELETE
command we can delete a particular row(s). So, Is it possible to delete entire data from a particular column in a table using onlyDELETE
command. (I know that usingUPDATE
command by setting null values to entire column we can achieve the functionality ofDELETE
).