TAILIEUCHUNG - The Language of SQL- P31

The Language of SQL- P31:Research has shown that, being pressed for time, most readers tend to skip the introduction of any book they happen to read and then proceed immediately to the first real chapter. With that fact firmly in mind, we will only cover relatively unimportant material in the introduction, such as an explanation of what you will and will not learn by reading this book. | 136 Chapter 13 Self Joins and Views FROM Customers LEFT JOIN Orders ON LEFT JOIN Refunds ON The only item missing in the above CREATE VIEW is the ORDER BY clause of the original SELECT statement. Since views aren t stored as physical data there is no point in including an ORDER BY clause in a view. Referencing Views When we execute the above CREATE VIEW statement it creates a view called CustomersOrdersRefunds. Creating the view does not return any data. It merely defines the view for later use. To use the view to bring back the same data as before we execute this SELECT statement SELECT FROM CustomersOrdersRefunds This retrieves First Name Last Name Order Date Order Amt Refund Date Refund Amt William Smith 2009-09-01 2009-09-02 Natalie Lopez 2009-09-02 NULL NULL Natalie Lopez 2009-10-03 2009-10-12 Brenda Harper 2009-09-15 NULL NULL Adam Petrie NULL NULL NULL NULL What if you only wanted to see a few columns from the view for one specific customer You could issue a SELECT statement such as SELECT First Name Last Name Order Date FROM CustomersOrdersRefunds WHERE Last Name Lopez Benefits of Views 137 The output is First Name Last Name Order Date Natalie Lopez 2009-09-02 Natalie Lopez 2009-10-03 It is important to note that when you reference columns in this view you need to specify the column alias names that were specified when the view was created. You can no longer reference original column names. For example the view assigns a column alias named First Name for the column. In Microsoft SQL Server these column aliases are enclosed in square brackets due to the embedded spaces in the names. DATABASE DIFFERENCES MySQL and Oracle As discussed in Chapter 2 MySQL and Oracle use different characters around columns containing spaces. MySQL uses the accent grave Oracle uses double quotes . Benefits of Views The previous example illustrates one of the

TỪ KHÓA LIÊN QUAN
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.