text, unitext, and image columns and readpast  Appendix A: The pubs2 Database

Chapter 21: Locking Commands and Options

Readpast-locking examples

The following examples illustrate readpast locking.

To skip all rows that have exclusive locks on them:

select * from titles readpast

To update only rows that are not locked by another session:

update titles 
    set price = price * 1.1 
    from titles readpast

To use readpast locking on the titles table but not on the authors or titleauthor table:

select *
    from titles readpast, authors, titleauthor
    where titles.title_id = titleauthor.title_id
    and authors.au_id = titleauthor.au_id

To delete only rows that are not locked in the stores table, but to allow the scan to block on the authors table:

delete stores from stores readpast, authors
where stores.city = authors.city




Copyright © 2005. Sybase Inc. All rights reserved. Appendix A: The pubs2 Database

View this book as PDF