TAILIEUCHUNG - SQL PROGRAMMING STYLE- P15

SQL PROGRAMMING STYLE- P15:Im mot trying to teach you to program in SQL in this book. You might want to read that again. If that is what you wanted, there are better books. This ought to be the second book you buy, not the first. I assume that you already write SQL at some level and want to get better at it. If you want to learn SQL programming tricks, get a copy of my other book, SQL for Smarties (3rd edition, 2005). | Improper Use of VIEWs 147 sex INTEGER DEFAULT 0 NOT NULL CHECK sex IN 0 1 2 And a CHECK constraint is simpler than creating VIEWs with the WITH CHECK OPTION. Exceptions None Single-Solution VIEWs Rationale Another past usage for VIEWs was to enable solutions where VIEWs really were the only way to solve a data access problem. Without VIEWs some complex data access requests could be encountered that were not capable of being coded using SQL alone. However sometimes a VIEW can be created to implement a portion of the access. Then the VIEW can be queried to satisfy the remainder. Consider the scenario where you want to report on detail information and summary information from a single table. For instance what if you would like to report on stock prices For each stock provide all stock details and also report the maximum minimum and average prices for that stock. Additionally report the difference between the average price and each individual price. CREATE VIEW StockSummary ticker_sym min_price max_price avg_price AS SELECT ticker_sym MIN price MAX price AVG price FROM Portfolio GROUP BY ticker_sym After the VIEW is created the following SELECT statement can be issued joining the VIEW to the base table thereby providing both detail and aggregate information on each report row SELECT - AS fluctuation FROM Portfolio AS P StockSummary AS S WHERE 148 CHAPTER 7 HOW TO USE VIEWS Situations such as these were ideal for using VIEWs to make data access a much simpler proposition. However the advent of table expressions sometimes referred to as in-line VIEWs makes this usage of VIEWs obsolete. Why Instead of coding the VIEW we can take the SQL from the VIEW and specify it directly into the SQL statement that would have called the VIEW. Using the previous example the final SQL statement becomes SELECT - .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.