Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting entire data from a particular column in oracle-sql

Recently I have started learning Oracle-sql. I know that with the help of DELETE command we can delete a particular row(s). So, Is it possible to delete entire data from a particular column in a table using only DELETE command. (I know that using UPDATE command by setting null values to entire column we can achieve the functionality of DELETE).

like image 744
RajeeV VenkaT Avatar asked Sep 26 '15 13:09

RajeeV VenkaT


People also ask

How do I delete data from a specific column in SQL?

Right-click on the table and go to Design. It shows all column of a particular table. Right-click on the left-hand side of a column and you get option Delete Column. Click on it to delete a column.


3 Answers

DELETE

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;
like image 139
Lukasz Szozda Avatar answered Oct 21 '22 13:10

Lukasz Szozda


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.

like image 43
mAEHS Avatar answered Oct 21 '22 15:10

mAEHS


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);
like image 1
Gordon Linoff Avatar answered Oct 21 '22 14:10

Gordon Linoff