Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: Database Administration >> Query to delete rows before 2007

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Query to delete rows before 2007
 sm_ahmeds  Posted: Sep 26, 2007 04:24:08 AM

 Total Post: 53
 Joined: Apr, 2007






 There is a table by the name SAMPLE in the ORACLE database.

There is a field namely LOGIN_DATE in the table

The format of this field is 01-JAN-07

I had to delete the rows from the table based on this field.

I had to delete all rows before 01-JAN-07

Please give me the query.

And also please tell give the query if table is linked to another table through foreign key or primary key

 Ramesh Joyisa
Posted: Sep 26, 2007 06:28:43 AM  

 Total Post: 226
 Joined: Aug, 2007






 
I hope that the LOGIN_DATE is a date field.
DELETE FROM SAMPLE WHERE LOGIN_DATE < to_date('01-JAN-07');

 sm_ahmeds
Posted: Sep 26, 2007 06:48:34 AM  

 Total Post: 53
 Joined: Apr, 2007






 
YES
HOWEVER THE TABLE HAS CHILD RECORDS

CAN U PLS TELL HOW TO DELETE CHILD RECORDS ASLO


THANKS

 krish
Posted: Oct 04, 2007 02:05:19 PM  

 Total Post: 4
 Joined: May, 2007






 
drop and recreate the foreign key constraint on child table using on delete cascade option
example:
alter table <tablename> add constraint <Constraint Name> foreign key(colanme) references Master_TABLE_NAME(primarykey col name) on delete cascade;

then delete the records in master.



 positive
Posted: Jun 29, 2008 02:55:39 PM  

 Total Post: 416
 Joined: Jun, 2008






 
To overcome problem of integrity constraints we can make use of ON DELETE CASCADE;

If not delete rows in parent table before deleting corresponding child records in dependent table.

Visit:

http://neworacledba.blogspot.com/

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar814
  Mohammed Taj704
  Jayanta Sur479
  positive fanatic416
  Vigyan Kaushik386
  Gitesh Trivedi322
  Gopu Gopi242
  neeraj sharma231
  Ramesh Jois226
  Bishal Khetan196






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software