開始使用免費開始

綜合練習

在這個練習中,你將綜合運用本課程中學到的多種技巧與概念,建立一個資料集,用來預測用於描述電影的文字與片語是否會影響租借次數。

首先,從 film 資料表的 description 欄位建立一個 tsvector。你會將它與一個 tsquery 比對,判斷片語「Astounding Drama」是否會帶來每月更高的租借量。接著,使用 similarity 函式建立一個新欄位,根據這個片語為電影描述進行排序。

本練習屬於課程

在 PostgreSQL 操作資料的函式

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

-- Select the title and description columns
SELECT  
  title, 
  description 
FROM 
  film
WHERE 
  -- Match "Astounding Drama" in the description
  ___(___) ___ 
  to_tsquery('Astounding & Drama');
編輯並執行程式碼