简体   繁体   English

使用指定的列进行选择不起作用

[英]Select with specified columns is not working

I have the following table in my PostgreSQL 10.1 database: 我的PostgreSQL 10.1数据库中有下表:

                                      Table "public.master_plan"
        Column        | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
----------------------+------+-----------+----------+---------+----------+--------------+-------------
   start_time_utc     | text |           |          |         | extended |              | 
   duration           | text |           |          |         | extended |              | 
   date               | text |           |          |         | extended |              | 
   team               | text |           |          |         | extended |              | 
   spass_type         | text |           |          |         | extended |              | 
   target             | text |           |          |         | extended |              | 
   request_name       | text |           |          |         | extended |              | 
   library_definition | text |           |          |         | extended |              | 
   title              | text |           |          |         | extended |              | 
   description        | text |           |          |         | extended |              | 

When I try the following sql query: 当我尝试以下sql查询时:

select title from master_plan;

it returns following error: 它返回以下错误:

ERROR:  column "title" does not exist
LINE 1: select title from master_plan;
               ^
HINT:  Perhaps you meant to reference the column "master_plan.  title".

What I'm doing wrong? 我做错了什么? This should work... 这应该工作...

You have spaces in the name. 名称中有空格。 Try this: 尝试这个:

alter table master_plan rename column "  title" to title;
select title from master_plan;

or 要么

alter table master_plan rename column "master_plan.  title" to title;
select title from master_plan;

You can see a running example at: http://rextester.com/LCXW46910 您可以在以下位置查看正在运行的示例: http : //rextester.com/LCXW46910

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM