我在 PostgreSQL 16 中有 IMDB 数据库,表为title_basics
. 该表包含多个列,包括titleSearchCol
类型为 的列tsvector
。当我尝试使用 psql 删除列时
ALTER TABLE title_basics DROP COLUMN titleSearchCol;
PostgreSQL 抛出错误
ERROR: column "titlesearchcol" of relation "title_basics" does not exist
我可以使用相同的语法查询表、添加更多列和删除其他列。我也尝试了 postgres 超级用户,导致了同样的错误信息。
查询表SELECT *...
显示列及其内容。\d title_basics
还显示列。
imdb_base=> \d title_basics
Table "public.title_basics"
Column Type Collation Nullable Default
-----------------------------------------------------------
tconst character varying not null
titletype character varying
primarytitle character varying
originaltitle character varying
isadult boolean
startyear numeric
endyear numeric
runtimeminutes character varying
genres character varying
titleSearchCol tsvector
Indexes:
"title_basics_pk" PRIMARY KEY, btree(tconst)
Referenced by:
TABLE "title_akas" CONSTRAINT "title_akas_title_basics_fk" FOREIGN KEY (titleid) REFERENCES title_basics(tconst) NOT VALID
TABLE "title_crew" CONSTRAINT "title_crew_title_basics_fk" FOREIGN KEY (tconst) REFERENCES title_basics(tconst) NOT VALID
TABLE "title_episode" CONSTRAINT "title_episode_title_basics_fk" FOREIGN KEY (parenttconst) REFERENCES title_basics(tconst) NOT VALID
TABLE "title_principals" CONSTRAINT "title_principals_title_basics_fk" FOREIGN KEY (tconst) REFERENCES title_basics(tconst) NOT VALID
TABLE "title_ratings" CONSTRAINT "title_ratings_title_basics_fk" FOREIGN KEY (tconst) REFERENCES title_basics(tconst) NOT VALID
如您所见,没有 column
titlesearchcol
,但有 columntitleSearchCol
。有人在名称中使用大写字母创建了该列(使用引号),现在只能使用引号使用该列,如下所示:ALTER TABLE title_basics DROP COLUMN "titleSearchCol";