MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 17th, 2004, 03:51 AM
kinx kinx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 kinx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sorry, how do I delete in SQL

I think its a really easy Q for those who know, I dont know a thing about sql but a contractor has stuffed me and I need to remove all the test data from a bunch of tables in a database.

Is there an easy way (or a way) to remove all the info in the rows of data in numerous tables without me messing up the tables for future use?

I though using query manager and just DELETE * FROM table_name

is that going to mess things up?

Appreciate the help.

Reply With Quote
  #2  
Old June 17th, 2004, 06:42 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 21 h 42 m 49 sec
Reputation Power: 37
Code:
DELETE FROM table_name


The * shouldn't be there. That will remove all records from the table.

Reply With Quote
  #3  
Old June 18th, 2004, 04:21 AM
kinx kinx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 kinx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
that is what I want, there are a few different tables and I just want to empty all the data that is there. Is there a difference?

Reply With Quote
  #4  
Old June 18th, 2004, 10:17 AM
redconfetti redconfetti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Orlando, FL
Posts: 2 redconfetti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to redconfetti
DELETE FROM table_name

Yes. That command will just straight out remove all the data in the table. It will not however reset the value for the auto_increment on the ID column you use in the table. I'm still trying to find out how to reset it.

Reply With Quote
  #5  
Old June 18th, 2004, 10:21 AM
kinx kinx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 kinx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks

Reply With Quote
  #6  
Old June 19th, 2004, 04:11 PM
lucasalexander lucasalexander is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Atlanta
Posts: 39 lucasalexander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to lucasalexander Send a message via MSN to lucasalexander
An alternative approach is "truncate table table_name."
__________________
Lucas Alexander
http://www.alexanderdevelopment.net

Reply With Quote
  #7  
Old June 19th, 2004, 06:00 PM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,007 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 h 41 m 31 sec
Reputation Power: 67
Quote:
Originally Posted by swampBoogie
The * shouldn't be there. That will remove all records from the table.

There is absolutely no difference between DELETE FROM table and DELETE * FROM table. Both commands delete all records.

Reply With Quote
  #8  
Old June 20th, 2004, 08:48 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 21 h 42 m 49 sec
Reputation Power: 37
The syntax

Code:
delete * from t


is specific to Access. It does not work in any other DBMS AFAIK,

Reply With Quote
  #9  
Old June 21st, 2004, 04:35 PM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,007 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 h 41 m 31 sec
Reputation Power: 67
I have to apologize...

I do not even work with Access, but I was so sure that DELETE * FROM was SQL standard (and understood by most DBMS that I know), that I didn't even bother to check it. But not even SQL Server accepts it...

I know better next time

Cheers
Thomas

Reply With Quote
  #10  
Old June 28th, 2004, 07:04 AM
rikb53 rikb53 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 4 rikb53 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 11 sec
Reputation Power: 0
delete or truncate?

why not do a truncate table?

TRUNCATE table table_name

thanks
rik

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > sorry, how do I delete in SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT