2016-05-19 15 views
2

を使用してインデックスを作成し、私はGINGiSTの両方を使用して索引を作成することができるよ:のPostgres:構文エラー<a href="http://www.postgresql.org/docs/9.4/static/pgtrgm.html" rel="nofollow">Postgres trgm docs</a>の指示に従いPRGM GIN

home_accounting_dev=# \d+ test_trgm 
        Table "public.test_trgm" 
Column | Type | Modifiers | Storage | Stats target | Description 
--------+------+-----------+----------+--------------+------------- 
t  | text |   | extended |    | 
Indexes: 
    "trgm_idx" gist (t gist_trgm_ops) 
    "trgm_idx_2" gin (t gin_trgm_ops) 
Has OIDs: no 

を...しかし、私はそうするように見えることはできません既存のテーブル "支出"、列 "desc"にある。

home_accounting_dev=# \d+ expenditures 
                  Table "public.expenditures" 
    Column |   Type    |       Modifiers       | Storage | Stats target | Description 
-------------+-----------------------------+-----------------------------------------------------------+----------+--------------+------------- 
id   | integer      | not null default nextval('expenditures_id_seq'::regclass) | plain |    | 
desc  | text      |               | extended |    | 
amount  | character varying(255)  |               | extended |    | 
inserted_at | timestamp without time zone | not null             | plain |    | 
updated_at | timestamp without time zone | not null             | plain |    | 
expent_at | date      |               | plain |    | 
Indexes: 
    "expenditures_pkey" PRIMARY KEY, btree (id) 
Referenced by: 
    TABLE "expenditures_taggings" CONSTRAINT "expenditures_taggings_assoc_id_fkey" FOREIGN KEY (assoc_id) REFERENCES expenditures(id) 
Has OIDs: no 

列は、この例とまったく同じタイプと特性テーブルtest_trgmの「T」の欄ですが、私は、インデックスを作成しようとすると、それは構文エラーがスローされます。

home_accounting_dev=# CREATE INDEX asdf_qwer ON expenditures USING gin (desc gin_trgm_ops); 
ERROR: syntax error at or near "desc" 
LINE 1: CREATE INDEX asdf_qwer ON expenditures USING gin (desc gin_t... 

それは、

home_accounting_dev=# CREATE INDEX asdf_qwer ON expenditures USING gin (dec gin_trgm_ops); 
ERROR: column "dec" does not exist 

答えて

2

desc予約語である:私は列名がmisstype場合は違っ失敗します。それを二重引用符で囲むとうまくいきます。

CREATE INDEX asdf_qwer ON expenditures USING gin ("desc" gin_trgm_ops); 
関連する問題