Search code examples
sqloraclesql-delete

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).


Solution

  • 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;