SQL Clearly Explained- P6

SQL Clearly Explained- P6: You don’t need to be a database designer to use SQL successfully. However, you do need to know a bit about how relational databases are structured and how to manipulate those structures. | 252 Chapter 10 Views Temporary Tables CTEs and Indexes Creating Indexes You create indexes with the CREATE INDEX statement CREATE INDEX index_name ON table_name index_key_columns For example to create an index on the author_last_first column in the author table someone at the rare book store could use CREATE INDEX author_name ON author author_first_last By default the index will allow duplicate entries and sort the entries in ascending order. To require unique index entries add the keyword UNIQUE after CREATE CREATE UNIQUE INDEX author_name ON author_first_last To sort in descending order insert DESC after the column whose sort order you to want to change. For example someone at the rare book store might want to create an index on sale_date in the sale relation in descending order so that the most recent sales are first CREATE INDEX sale_date ON sale sale_date DESC If you want to create an index on a concatenated key you include all the columns that should be part of the index key in the column list. For example the following creates an index organized by title and author number CREATE INDEX book_order ON book title author_ numb Please purchase PDF Split-Merge on to remove this watermark. How Much Faster 253 Although you do not need to access an index directly unless you want to delete it from the database it helps to give indexes names that tell you something about their keys. This makes it easier to remember them should you need to get rid of the indexes. Please purchase PDF Split-Merge on to remove this watermark. Keeping the Design Up to Date Modifying Tables One of the benefits that relational DBMSs have over DBMSs based on older data models is that the schema is easy to change. As long as a table isn t being used at the time you want to modify it its design can be changed without affecting other tables in the database. This is said with the caveat that the presence of foreign key constraints may prevent some deletions and .

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
27    70    2    12-05-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.