GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  Data Access
Go To First  |  Previous Question  |  Next Question 
 Data Access  |  Question 17 of 27    Print  
can we delete tuples in a table based on date column? And how?

  
Total Answers and Comments: 3 Last Update: June 10, 2009   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 17, 2005 07:35:33   #1  
Brijesh Singh        

RE: can we delete tuples in a table based on date colu...
use this SQL query :delete from student_tab A where ROWID > ( select min(ROWID) from student_tab B where A.roll_number B.roll_number);Note : Table Name student_tab Key to table roll_number
 
Is this answer useful? Yes | No
September 05, 2006 06:16:19   #2  
vishnu        

RE: can we delete tuples in a table based on date colu...
If you want to delete rows with given DATE

DELETE FROM TABLE_NAME WHERE DATE_COLUMN GIVEN DATE;



If you want to delete rows > given DATE

DELETE FROM TABLE_NAME WHERE DATE_COLUMN > GIVEN DATE;



If you want to delete rows < given DATE

DELETE FROM TABLE_NAME WHERE DATE_COLUMN < GIVEN DATE;



If you want to delete rows BETWEEN DATE1 and DATE2

DELETE FROM TABLE_NAME WHERE DATE_COLUMN BETWEEN DATE1 AND DATE2;

 
Is this answer useful? Yes | No
June 10, 2009 04:53:09   #3  
MaheshRamekar Member Since: June 2009   Contribution: 3    

RE: can we delete tuples in a table based on date column? And how?

SQL> create table m( n number);

Table created.


1* insert into m values(&1)
SQL> /
Enter value for 1: 1
old 1: insert into m values(&1)
new 1: insert into m values(1)

1 row created.

SQL> /
Enter value for 1: 2
old 1: insert into m values(&1)
new 1: insert into m values(2)

1 row created.

SQL> /
Enter value for 1: 3
old 1: insert into m values(&1)
new 1: insert into m values(3)

1 row created.

SQL> /
Enter value for 1: 4
old 1: insert into m values(&1)
new 1: insert into m values(4)

1 row created.

SQL> /
Enter value for 1: 1
old 1: insert into m values(&1)
new 1: insert into m values(1)

1 row created.

SQL> /3
Enter value for 1: 3
old 1: insert into m values(&1)
new 1: insert into m values(3)

1 row created.

SQL> /
Enter value for 1: 4
old 1: insert into m values(&1)
new 1: insert into m values(4)

1 row created.

SQL> /
Enter value for 1: 1
old 1: insert into m values(&1)
new 1: insert into m values(1)

1 row created.

SQL> /
Enter value for 1: 3
old 1: insert into m values(&1)
new 1: insert into m values(3)

1 row created.

SQL> select * from m;

N
----------
1
2
3
4
1
3
4
1
3

9 rows selected.

SQL> commit;

Commit complete.

SQL> delete from m where rowid not in( select min(rowid) from m group by n);

5 rows deleted.

SQL> select * from m;

N
----------
1
2
3
4


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape