<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    Chapter 1:  General Information 37 \Atomic," in the sense that we mean it, is nothing magical.   It only means that you can be sure that while each speci c update is running, no other user can interfere with it, and there will never be an automatic rollback (which can happen with transactional tables if you are not very careful).  MySQL Server also guarantees that there will not be any dirty reads. Following are some techniques for working with non-transactional tables:    Loops that need transactions normally can be coded with the help of LOCK TABLES, and you don't need cursors when you can update records on the y.    To avoid using ROLLBACK, you can use the following strategy: 1.   Use LOCK TABLES ... to lock all the tables you want to access. 2.   Test conditions. 3.   Update if everything is okay. 4.   Use UNLOCK TABLES to release your locks. This is usually a much faster method than using transactions with possible ROLLBACKs, although not always.  The only situation this solution doesn't handle is when someone kills the threads in the middle of an update.  In this case, all locks will be released but some of the updates may not have been executed.    You can also use functions to update records in a single operation.  You can get a very ecient application by using the following techniques:    Modify elds relative to their current value.    Update only those elds that actually have changed. For  example,  when  we  are  doing  updates  to  some  customer  information,  we  update only the customer data that has changed and test only that none of the changed data, or data that depends on the changed data, has changed compared to the original row. The test for changed data is done with the  WHERE  clause in the  UPDATE  statement.  If the record wasn't updated, we give the client a message:  "Some of the data you have changed has been changed by another user." Then we show the old row versus the new row in a window, so the user can decide which version of the customer record he should use. This gives us something that is similar to column locking but is actually even better because we only update some of the columns,  using values that are relative to their current values.  This means that typical UPDATE statements look something like these: UPDATE tablename SET pay_back=pay_back+'relative change'; UPDATE customer SET customer_date='current_date', address='new address', phone='new phone', money_he_owes_us=money_he_owes_us+'new_money' WHERE customer_id=id AND address='old address' AND phone='old phone'; As you can see, this is very ecient and works even if another client has changed the values in the pay_back or money_he_owes_us columns.
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    MERCHANT ACCOUNTS
    DEDICATED SERVERS
    E-COMMERCE HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN
    REGISTRATION
    MANAGE
    YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    Corporate Info
    ABOUT US
    OUR NETWORK
    CONTACT US
    SITE MAP
    Copyright © 2002 Dyntex Group, Inc. All Rights Reserved
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide