Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    delete rows from table

    hi, how do i delete all the rows from a table? means there will be no data in the table. thanks!

  • #2
    New Coder
    Join Date
    Oct 2002
    Location
    nj
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's the syntax:


    Delete tablename

    for example to delete all rows from employee table:

    delete employee


    Thanks,
    Ray

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well actuall it should be

    DELETE FROM tablename

    without a where clause to delete all the rows. However a faster method is to truncate the table

    TRUNCATE TABLE table_name

    Instead of deleting the rows one at a time it drops the tables and then recreates it.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    New Coder
    Join Date
    Oct 2002
    Location
    nj
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for correcting I was using a MS-SQL syntax, and did not realized it......

    However, just a note that when using the

    DELETE FROM tablename

    this will return zero as the number of affected records

    To determine how many records were actually deleted, you can use the following


    DELETE FROM TableName where 1>0

    Thanks ...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •