New answers tagged


In this query: select next value for schema_name.sequence_name; next value is creating problem because we can not make the spaces while writing a query. So other thing you can do is found the max of value and increase it by 1. Below find query for that: select max(value)+1 for schema_name.sequence_name; This would be helpful for you.


I want to know what the id of the next row I insert will be. How can I tell this, without inserting a row? This is exactly what nextval() does. But I can't think of any useful thing to do with this value, if you are not inserting into the table. It will be the id value of a row that may never be inserted: Important: To avoid blocking concurrent ...


There are a couple of misunderstandings floating around here. OIDs were included with every row by default every row in very old versions of Postgres. The default was soon changed to not include OID columns in user-defined tables. Quoting the Postgres 8.1 documentation: default_with_oids (boolean) This controls whether CREATE TABLE and CREATE ...


OIDS From Docs The oid type is currently implemented as an unsigned four-byte integer. Therefore, it is not large enough to provide database-wide uniqueness in large databases, or even in large individual tables. So, using a user-created table's OID column as a primary key is ...


You need to select from something. Another option is: db2 => values next value for schema_name.sequence_name; As you noted you can also use SYSIBM.SYSDUMMY1 or create a virtual table: db2 => select next value for schema_name.sequence_name from ( values 1 );


db2 => select next value for schema_name.sequence_name from SYSIBM.SYSDUMMY1; did the trick


From You must own the sequence to use ALTER SEQUENCE. To change a sequence's schema, you must also have CREATE privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have CREATE privilege on the sequence's ...


I had to execute a query despite using SQLALchemy because I wasn't successful of using currval. nextId = db.session.execute("select last_value from <table>_seq").fetchone()[0] + 1 This was a python flask + postgresql project.

Top 50 recent answers are included