postgresl:在id上搜索没有结果

时间:2017-10-19 12:05:25

标签: postgresql

DB:postgresql 9.5

使用字段名称进行搜索时返回结果,但在使用id进行搜索时不返回结果。

somedb=# select id from users where name='abc';
  id  
------
 123
(1 row)

somedb=# select id from users where id=123;
 id 
----
(0 rows)

bigquant_jupyterhub=# \d users;
                                       Table "public.users"
    Column     |            Type             |                     Modifiers                      
---------------+-----------------------------+----------------------------------------------------
 id            | integer                     | not null default nextval('users_id_seq'::regclass)
 name          | character varying(1023)     | 
 _server_id    | integer                     | 
 admin         | boolean                     | 
 last_activity | timestamp without time zone | 
 cookie_id     | character varying(1023)     | 
 state         | text                        | 
 auth_state    | text                        | 
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "users__server_id_fkey" FOREIGN KEY (_server_id) REFERENCES servers(id)
Referenced by:
    TABLE "api_tokens" CONSTRAINT "api_tokens_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id)
    TABLE "user_group_map" CONSTRAINT "user_group_map_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id)

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

reindex解决了这个问题。谢谢大家。