GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL Plus

 Print  |  
Question:  How many ways you can delete the table records ?

Answer: In how many ways can I delete all the contents of a table and the entire table. Explain with syntax ?


May 05, 2009 04:22:02 #4
 priyaraja2k2   Member Since: May 2009    Total Comments: 1 

RE: How many ways you can delete the table records ?
 

We have 2 options :


1. Delete

2.Truncate


Delete : It is DML concepts.

Syntax: Delete from <table_name>;

Example: Delete from emp;

Explain: The above query will delete all the record from the tale. Supose need
to delete the particular record from the table ,we can give the condition.


Syntax: Delete from <table_name> where <condition>

Example: Delete from emp where emp_no =101;

Explain: By default You gave the condition 101 instead of 1001. You can Rollback
and get the 101 record before doing commit.


Truncate : It is DDL commend.

Syntax: Truncate Table <Table_Name>;

Example: Truncate Table Emp;

Explain: The above query will delete all the record from the table. Suppose need
to delete the particular record from the table, we cannot give the condition.

Once we truncate the table we cannot Rollback.


DROP : Remove the table from data base.

Syntax: Drop Table <Table_Name>

Example : Drop Table Emp;

     

 

Back To Question