Advanced SQL Database Programmer phần 5

Có bao phấn vị của hình thức (x IS NOT] NULL) trong SQL mà lối thoát hiểm bởi vì bạn không thể sử dụng (x = NULL) để kiểm tra một giá trị NULL. Hầu như tất cả các vị khác trong SQL tự khắc phục với chuỗi ba nhà khai thác. Trong mệnh đề WHERE, các hàng kiểm tra FALSE hoặc UNKNOWN được loại bỏ khỏi bảng. | x NOT TRUE FALSE UNK UNK FALSE TRUE AND TRUE UNK FALSE TRUE TRUE UNK FALSE UNK UNK UNK FALSE FALSE FALSE FALSE FALSE OR TRUE UNK FALSE TRUE TRUE TRUE TRUE UNK TRUE UNK UNK FALSE TRUE UNK FALSE There is anther predicate of the form x IS NOT NULL in SQL that exits because you cannot use x NULL to test for a NULL value. Almost all other predicates in SQL resolve themselves to chains of these three operators. In the WHERE clause the rows that test FALSE or UNKNOWN are removed from the table. Now you are probably thinking that if we are going to treat FALSE and UNKNOWN alike then why go to all the trouble to define a three-valued logic in the first place Defining a Three-valued Logic SQL has three sub-languages DML DDL and DCL. The Data Control Language DCL controls user access to the database and does not use predicates. In the Data Manipulation Language DML users can ask queries SELECT statements or change the data INSERT INTO UPDATE and DELETE FROM statements . The Data Declaration Language DDL is where administrators control the schema objects like tables views stored procedures and so forth. The FALSE and UNKNOWN remove rows from the results of a query in the DML. In the DDL a TRUE or UNKNOWN test result in a CHECK constraint will preserve a row -- give it the benefit of 39 oracle the doubt so to speak. Otherwise no column could be NULLable. Wonder Shorthands SQL also came up with some wonder shorthands that improve the readability of the code. The logical operator x bEtWEEN y AND z means y x aNd x z -note the order of comparison and the inclusion of the endpoints of the range. Likewise x IN a b c . expands out to x a OR x b OR x c OR . at run time. Most SQL engines are pretty good about optimizing the predicates and not that good about optimizing calculations. For example the engine might not change x 0 or x 1 to x when they are compiling the code. This means that you need to write very clear logical expression with the simplest calculations in

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
46    136    7    16-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.