Results 1 to 2 of 2

 

Thread: Replace into?

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Sep 2003
    Posts
    315
    Thanks
    28
    Thanked 19 Times in 16 Posts


    Hi everyone

    Today I saw reference to a MYSQL command that I've surprisingly not seen before - REPLACE INTO

    I'm trying to find out what it does, and what it's benefits, if any, over INSERT INTO and UPDATE are.

    Any help would be much appreciated.

    Thanks!

    Tom

  2. #2
    scriptmonkey's Avatar
    Oranges & Lemons

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Worthing
    Posts
    1,607
    Thanks
    112
    Thanked 253 Times in 192 Posts
    Hi Tom

    REPLACE INTO has, in my view, outlived it's usefulness with successive releases of mysql. (as well as rewriting the primary key if used)

    If you have a unique key on your table and in your data, then INSERT INTO will just miss out existing rows, UPDATE will update the existing rows, whereas REPLACE INTO will delete the existing row, then create a new one (which is both memory hungry, and, where the primary key gets changed, unless you don't have an autonumber PK).

    In essence, it's not really useful any more.

    Tony
    The trouble with the rat race is that even if you win you're still a rat.
    Time passes. Listen. Time passes. Dylan Thomas
    Ebay Alerts to your inbox

  3. The Following User Says Thank You to scriptmonkey For This Useful Post:

    Tobman (24-01-11)



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Content Relevant URLs by vBSEO 3.5.0 RC2