java2db

Delete a record from the table with sql



DELETE is used to delete a record /records  from the table .

 

DELETE Prerequisites :

DELETE For you to delete a record or records  from a table,the table must be in your own schema or you

must have the DELETE object privilege on the table.

DELETE For you to delete a record from an updatable materialized view, the materialized view must be in

your own schema or you must have the DELETE object privilege on the materialized view.

DELETE For you to delete rows from the base table of a view, the owner of the schema containing the view

must have the DELETE object privilege on the base table. Also, if the view is in a schema other than

your own, you must have the DELETE object privilege on the view.

DELETE The DELETE ANY TABLE system privilege also allows you to delete rows from any table or table

partition or from the base table of any view.

 

Example table ( EMP_DETAILS ).

E_NO
E_NAME
E_GENDER
E_SALARY
E_ADDRESS
E_JOIN_DATE
E_IN_TIME
1 Rose S F 10000 street10,xxx,UK 03-MAR-13 10-MAR-13 12.10.10.0
2 Tom M 15000 street11,xxx,UK 04-MAY-13 12-MAY-13 12.10.10.0
3 Jerry F 13000 street122,xxx,UK 05-JAN-13 15-JAN-13 12.10.10.0

To delete a record from the table with sql, follow the syntax.

Syntax:

DELETE   FROM <table_name> WHERE <condition> ;

 

Example query to delete a record / records:

Execution result :

E_NO
E_NAME
E_GENDER
E_SALARY
E_ADDRESS
E_JOIN_DATE
E_IN_TIME
1 Rose S F 10000 street10,xxx,UK 03-MAR-13 10-MAR-13 12.10.10.0
3 Jerry F 13000 street122,xxx,UK 05-JAN-13 15-JAN-13 12.10.10.0

 

 

Note: Must specify a where clause .Otherwise the SQL statement will delete all the records from the table.

Execution result :

E_NO
E_NAME
E_GENDER
E_SALARY
E_ADDRESS
E_JOIN_DATE
E_IN_TIME



Related Posts :
Sql FOREIGN KEY constraint on table column
Sql CHECK constraint on table column
Sql NOT NULL constraint on table column
Sql UNIQUE constraint on table column
Sql PRIMARY KEY constraint on table column
Sql full outer join on tables with an example
Sql right outer join on tables with an example
Sql left outer join on tables with an example
   [will not be published]



^ <