使用指定列进行选择无效

问题描述 投票:0回答:1

我的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 |              | 

当我尝试以下sql查询时:

select title from master_plan;

它返回以下错误:

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

我做错了什么?这应该工作......

sql postgresql
1个回答
0
投票

名称中有空格。试试这个:

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

要么

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

您可以在以下位置查看正在运行的示例:http://rextester.com/LCXW46910

© www.soinside.com 2019 - 2024. All rights reserved.