模式中的 postgresql 序列 nextval

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21397601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:35:45  来源:igfitidea点击:

postgresql sequence nextval in schema

postgresqlpostgresql-9.3

提问by carlos

I have a sequence on postgresql 9.3 inside a schema.

我在模式中的 postgresql 9.3 上有一个序列。

I can do this:

我可以做这个:

SELECT last_value, increment_by from foo."SQ_ID";

SELECT last_value, increment_by from foo."SQ_ID";

last_value | increment_by
------------+--------------
          1 |            1 (1 fila)

but this not Works:

但这不起作用:

SELECT nextval('foo.SQ_ID');

SELECT nextval('foo.SQ_ID');

ERROR:  no existe la relación ?foo.sq_id?
LíNEA 1: SELECT nextval('foo.SQ_ID');

What is wrong ?

怎么了 ?

It says that not exist the relation ?foo.sq_id?, but it exists.

它说不存在关系?foo.sq_id?,但它存在。

回答by Craig Ringer

The quoting rules are painful. I think you want:

引用规则是痛苦的。我想你想要:

SELECT nextval('foo."SQ_ID"');

to prevent case-folding of SQ_ID.

以防止SQ_ID.

回答by Raghulan Gowthaman

SELECT last_value, increment_by from "other_schema".id_seq;

for adding a seq to a column where the schema is not public try this.

要将 seq 添加到架构不公开的列,请尝试此操作。

nextval('"other_schema".id_seq'::regclass)