TAILIEUCHUNG - Học php, mysql và javascript - p 21

Một khi bạn đã gõ vào các lệnh này, kết quả sẽ giống như các ảnh chụp màn hình trong hình 8-8. Lưu ý rằng các từ khóa PRIMARY KEY thay thế INDEX từ khóa trong cú pháp ALTER TABLE (so sánh ví dụ 8-10 và 8-13). Để có tạo ra một khóa chính khi bàn kinh điển đã được tạo ra, bạn có thể đã sử dụng | Figure 8-8. Retrospectively adding a primary key to the classics table uses the UPDATE and WHERE keywords which are explained in more detail in the upcoming section Querying a MySQL Database on page 183. Example 8-13. Populating the isbn column with data and using a primary key ALTER TABLE classics ADD isbn CHAR 13 UPDATE classics SET isbn 9781598184891 WHERE year 1876 UPDATE classics SET isbn 9780582506206 WHERE year 1811 UPDATE classics SET isbn 9780517123201 WHERE year 1856 UPDATE classics SET isbn 9780099533474 WHERE year 1841 UPDATE classics SET isbn 9780192814968 WHERE year 1594 ALTER TABLE classics ADD PRIMARY KEY isbn DESCRIBE classics Once you have typed in these commands the results should look like the screenshot in Figure 8-8. Note that the keywords PRIMARY KEY replace the keyword INDEX in the ALTER TABLE syntax compare Examples 8-10 and 8-13 . To have created a primary key when the table classics was created you could have used the commands in Example 8-14. Again rename classics in line 1 to something else if you wish to try this example for yourself and then delete the test table afterward. Example 8-14. Creating the classics table with indexes CREATE TABLE classics author VARCHAR 128 title VARCHAR 128 category VARCHAR 16 year SMALLINT isbn CHAR 13 INDEX author 20 INDEx title 20 INDEx category 4 Indexes 181 INDEX year PRIMARY KEY isbn ENGINE MyISAM Creating a FULLTEXT index Unlike a regular index MySQL s FULLTEXT allows super-fast searches of entire columns of text. What it does is it stores every word in every data string in a special index that you can search using natural language in a similar manner to using a search engine. Actually it s not strictly true that MySQL stores all the words in a FULLTEXT index because it has a built-in list of more than 500 words that ta it chooses to ignore because they are so common that they aren t very helpful when searching anyway. This list called stopwords includes the as is of and so on. The list helps MySQL

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.