首页 > 解决方案 > 当名称实际上是大写时,如何使用确保表名是小写的查询?

问题描述

当名称实际上是大写时,如何使用确保表名是小写的查询?

- ERROR:  relation "public.billed" does not exist
- LINE 1: SELECT count(1) FROM public.BILLED
                             ^
- QUERY:  SELECT count(1) FROM public.BILLED
- CONTEXT:  PL/pgSQL function count_rows(text,text) line 7 at EXECUTE - - statement

标签: postgresqlfunction

解决方案


在 postgres 中,如果您不使用双引号,则 db 假定为小写。所以在你的情况下你需要使用

SELECT count(1) FROM public."BILLED"

推荐阅读