Ad Code

Responsive Advertisement

SQL DELETE

 

SQL DELETE



Portrayal 

The Oracle DELETE statement is used to remove a special record or multiple records from a table in Oracle. 

Syntax 

The DELETE statement syntax in Oracle/PLSQL is as follows:

DELETE FROM table_name WHERE condition;


Settings or restraints 

Table 

Scene from which you want to delete records. 

Where conditions 

Optional. The conditions for the records to be deleted. If no conditions are provided, all records on the table will be deleted. 

Note 

You don't need to list the Oracle DELETE statement fields since you remove the entire line from the table.


Example - Using a condition 

Let's look at an example of An Oracle DELETE straightforward query, where we have only one condition in the DELETE statement. 

      Standard example:


DELETE FROM  Article  WHERE num_Article='A200';


      In this statement, 

  • Promote first, you specify the name of the table from which you want to delete data. 

  • Second, you specify which line should be removed using the condition in the WHERE provision. If you miss the WHERE provision, the Oracle DELETE statement removes all the lines from the table.


Example - Use of two conditions 

Let's look at an example Oracle DELETE, where we have only two conditions in the DELETE statement. 

      Standard example:



DELETE FROM  Article  WHERE num_Article='A200' and Name='Jeans';



Delete all records 

It is conceivable to remove all lines from a table without removing the scene. This means that the structure, attributes and lists of the table will be intact:

    Standard example:


DELETE FROM  Article;



ORACLE DELETE EXAMPLES


EXAMPLE 01;

Let's create a new table called deals , which contains all the sales order data, to demo scales:


        Table DEALS


 Deals( *id_deals , Name , Price_Sale , QTS , Price_Purchase );


  •  *  :   Means Primary Key 
        

         Let's Create Table In Oracle (SQL)




Create Table Deals (

       id_deals Number
 
       Name Varchar2(20),
 
       Price_Sales Number(7,2),

       QTS Number,

       Price_Purchase Number(7,2),

Constraint PK_Sales Primary Key(Id_deals));
       
      

ORACLE DELETE - remove a line from a table 


The following statement removes a line with a command id of 1 and the item id is 1:



DELETE FROM  DEALS  WHERE id_deals='1';


     ORACLE restored the accompanying message: 


1 ROW DELETED.





ORACLE DELETE - Use of two conditions


The following statement deletes a row whose  id_deals is 1 and price_sales is 100:


DELETE FROM  DEALS  WHERE id_deals='1' and price_sales='1';


    ORACLE restored the accompanying message: 



1 ROW DELETED.


ORACLE DELETE - Remove multiple rows from a TABLE


The following statement removes a line with a command Name  equals Jeans :



DELETE FROM  DEALS  WHERE Name='Jeans';


    ORACLE restored the accompanying message: 



16 ROW DELETED.



ORACLE DELETE - DELETE ALL ROWS 



DELETE FROM  DEALS;



    ORACLE restored the accompanying message: 



99 ROW DELETED.





EXAMPLE 02;

Let's create a new table called Client , which contains all the sales order data, to demo scales:


        Table DEALS


 EMPLOYER*id_Employer , FIRST_Name , LAST_NAME , AGE , profession);


  •  *  :   Means Primary Key 
        

         Let's Create Table In Oracle (SQL)




Create Table EMPLOYER (

       id_Employer Number , 
 
       First_Name Varchar2(20),
 
       Last_Name Varchar(20),

       AGE Number,

       Profession Varchar2(20),

Constraint PK_Employer Primary Key(id_Employer));
       
      

ORACLE DELETE - remove a line from a table 


The following statement removes a line with a command id of 1 and the item id is 1:



DELETE FROM  EMPLOYER  WHERE id_Employer='1';


     ORACLE restored the accompanying message: 


1 ROW DELETED.





ORACLE DELETE - Use of two conditions


The following statement deletes a row whose  FIRST_name is Alfred  and profession is Director :


DELETE FROM  EMPLOYER  WHERE First_Name='Alfred' and 

Profession='director';


    ORACLE restored the accompanying message: 



1 ROW DELETED.


ORACLE DELETE - Remove multiple rows from a TABLE


The following statement removes a line with a command First_Name  equals Alfred:



DELETE FROM  EMPLOYER  WHERE First_Name='Alfred';


    ORACLE restored the accompanying message: 



6 ROW DELETED.



ORACLE DELETE - DELETE ALL ROWS 



DELETE FROM  EMPLOYER;



    ORACLE restored the accompanying message: 



99 ROW DELETED.





ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE

ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE

ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE
ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE

ORACLE

 DELETE - DELETE 

 DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE  DELETE - DELETE 

 ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE

ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE

ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE

ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE

Post a Comment

0 Comments