1. Trang chủ
  2. » Giáo Dục - Đào Tạo

joe celko's sql for smarties [electronic resource] advanced sql programming, fourth edition

792 337 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 792
Dung lượng 10,82 MB

Nội dung

[...]... objects and the rules under which they operate The data is the meat on that skeleton The only data structure in SQL is the table Tables can be p ­ ersistent (base tables), used for working storage (temporary tables), virtual (VIEWs, common table expressions, and derived Joe Celko’s SQL for Smarties DOI: 10.1016/B978-0-12-382022-8.00003-X Copyright © 2011 by Elsevier Inc All rights reserved 23 24   Chapter... A5B are useful only for distinguishing isolation levels below REPEATABLE READ in strength The ANSI SQL definition of REPEATABLE READ, in its strict interpretation, captures a degenerate form of row constraints, but misses the general concept To be specific, Locking REPEATABLE READ of Table 2 provides protection from Row Constraint Violations, but the ANSI SQL definition of Table 1, forbidding anomalies... and wait for their missing resource to become available; it never happens The common solution for 22   Chapter 2  TRANSACTIONS AND CONCURRENCY CONTROL a deadlock is for the database administrator (DBA) to kill one or more of the sessions involved and rollback his or her work A livelock involves a user who is waiting for a resource, but never gets it because other users keep grabbing it before he or... execute zero or more Joe Celko’s SQL for Smarties DOI: 10.1016/B978-0-12-382022-8.00002-8 Copyright © 2011 by Elsevier Inc All rights reserved 11 12   Chapter 2  TRANSACTIONS AND CONCURRENCY CONTROL transactions As one user inserts, updates, and deletes rows in the database, these changes are not made a permanent part of the database until that user issues a COMMIT WORK command for that transaction... the same time In Chapter 2  TRANSACTIONS AND CONCURRENCY CONTROL   15 the  SQL model, there are three ways that one transaction can affect another • P0 (Dirty Write): Transaction T1 modifies a data item Another transaction T2 then further modifies that data item before T1 performs a COMMIT or ROLLBACK If T1 or T2 then performs a ROLLBACK, it is unclear what the correct data value should be One reason... Transaction T1 modifies a row Transaction T2 then reads that row before T1 performs a COMMIT WORK If T1 then performs a ROLLBACK WORK, T2 will have read a row that was never committed, and so may be considered to have never existed • P2 (Nonrepeatable read): Transaction T1 reads a row Transaction T2 then modifies or deletes that row and performs a ­ OMMIT C WORK If T1 then attempts to reread the row, it... Critique of ANSI SQL Isolation Levels,” by Hal Berenson, Phil Bernstein, Jim Gray, Jim Melton, Elizabeth O’Neil, and Patrick O’Neil (1995) 2.3.2  The Isolation Levels In standard SQL, the user gets to set the isolation level of the transactions in his session The isolation level avoids some of the phenomena we just talked about and gives other information to the database The syntax for the explains itself The READ ONLY option means that this is a query and lets the SQL engine know that it can relax a bit The READ WRITE option lets the SQL engine know that rows might be changed, and that it has to watch out for the three phenomena The important clause, which is implemented in most current SQL products, is the clause The isolation level 18   Chapter 2  TRANSACTIONS... data moves from SQL to the host language, it has to be converted into host language data types and data structures to be displayed and used The host languages have file systems built into them The big differences between working with a file system and working with SQL are in the way SQL fits into a host program Using a file system, your programs must open and close files individually In SQL, the whole... but that is established as part of the connection The program defines fields within a file, whereas SQL defines its columns in the schema FORTRAN uses the FORMAT and READ statements to get data from a file Likewise, a COBOL program uses a Data Division to define the fields and a READ to fetch it And so on for every 3GL’s programming; the concept is the same, though the syntax and options vary A file system . xxi INTRODUCTION TO THE FOURTH EDITION This book, like the first, second, and third editions before it, is for the working SQL programmer who wants to pick up some advanced programming tips. Morgan Kaufmann: • SQL for Smarties (1995, 1999, 2005, 2010) • SQL Puzzles and Answers (1997, 2006) • Data and Databases (1999) • Trees and Hierarchies in SQL (2004) • SQL Programming Style. required SQL- 92 conformance for federal contracts. We had the FIPS-127 conformance test suite in place during the development of SQL- 92, so all the vendors could move in the same direction. Unfortunately,

Ngày đăng: 31/05/2014, 01:20

TỪ KHÓA LIÊN QUAN