重命名 postgres 中的列时出错
Error while renaming the column in postgres
我通过以下方式创建了新的 table:
CREATE TABLE DIFF_ODATE_PERIOD AS
select test_3.odate - test_3.max_period from test_3;
它给了我列名:?column?
当我尝试更改名称时出现错误:
ALTER TABLE DIFF_ODATE_PERIOD
RENAME COLUMN ?column? TO test;
ERROR: syntax error at or near "?" LINE 71: RENAME COLUMN ?column?
TO test;
我可以在创建时或之后定义名称吗?
您需要直接在 create table ... as select
语句中为该列添加别名:
create table diff_odate_period as
select odate - max_period as test from test_3;
我通过以下方式创建了新的 table:
CREATE TABLE DIFF_ODATE_PERIOD AS
select test_3.odate - test_3.max_period from test_3;
它给了我列名:?column?
当我尝试更改名称时出现错误:
ALTER TABLE DIFF_ODATE_PERIOD
RENAME COLUMN ?column? TO test;
ERROR: syntax error at or near "?" LINE 71: RENAME COLUMN ?column? TO test;
我可以在创建时或之后定义名称吗?
您需要直接在 create table ... as select
语句中为该列添加别名:
create table diff_odate_period as
select odate - max_period as test from test_3;