Giới thiệu các extension của PostgreSQL

Các hàm thao tác dữ liệu trong PostgreSQL

Brian Piccolo

Sr. Director, Digital Strategy

Giới thiệu các extension của PostgreSQL

Các extension thường dùng

  • PostGIS
  • PostPic
  • fuzzystrmatch
  • pg_trgm
Các hàm thao tác dữ liệu trong PostgreSQL

Truy vấn siêu dữ liệu về extension

Extension khả dụng

SELECT name
FROM pg_available_extensions;
+--------------------+
| name               |
|--------------------|
| dblink             | 
| pg_stat_statements | 
+--------------------+

Extension đã cài đặt

SELECT extname 
FROM pg_extension;
+---------+
| name    |
|---------|
| plpgsql |
+---------+
Các hàm thao tác dữ liệu trong PostgreSQL
--Enable the fuzzystrmatch extension
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
--Confirm that fuzzstrmatch has been enabled
SELECT extname FROM pg_extension;
+---------------+
| name          |
|---------------|
| plpgsql       |
| fuzzystrmatch |
+---------------+
Các hàm thao tác dữ liệu trong PostgreSQL

Dùng fuzzystrmatch cho tìm kiếm mờ

SELECT levenshtein('GUMBO', 'GAMBOL');
+-------------+
| levenshtein |
|-------------|
|           2 |
+-------------+
Các hàm thao tác dữ liệu trong PostgreSQL

So sánh hai chuỗi với pg_trgm

SELECT similarity('GUMBO', 'GAMBOL');
+------------+
| similarity |
|------------|
| 0.18181818 |
+------------+
Các hàm thao tác dữ liệu trong PostgreSQL

Hãy thực hành!

Các hàm thao tác dữ liệu trong PostgreSQL

Preparing Video For Download...