I want set some constraint to the serial type,it only produce even or odd numbers.
serial type produce only even or odd numbers in postgresql
2.3k Views Asked by yjfuk At
2
There are 2 best solutions below
Related Questions in POSTGRESQL
- Why does adding a JOIN completely modify the query planner behaviour?
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Aggregate and count in PostgreSQL
- Rails HABTM: Select everything a that a record 'has'
- Trigger using data from inserted row
- Select results where joined table contains records with an attribute, but without another
- DB candidate as CouchDB/Schema replacement
- How do I properly add data in SQLAlchemy?
- Postgres in Conda Environment (Ubuntu 14.04)
- How to customize the output of the Postgres Pseudo Encrypt function?
- Split a large query (2 days) into pieces to increase the speed in Postgres
- Why does pg_search prefix not work like I expect?
- extracting meta info from a table psql using information_schema
- How to query a table in the database and copy it's data into one one?
- Update a table using info from a second table and a condition from a third table in Postgresql
Related Questions in AUTO-INCREMENT
- MySQL Autoincrement on Same variable for Two Tables
- MySQL Field AUTO_INCREMENT according to YEAR
- Insert a row to some tables with same id
- MySQL Auto-Increment with several different user-input words
- SQLAlchemy bulk insert auto-incremment
- MySQL: How to create table with auto incrementing column via script
- PostgreSQL Auto-increment inside a JSON
- why is auto-increment trigger creation in oracle failing?
- How to create auto-increment ID's in CloudKit JS?
- Is there a way to auto increment a column with respect to the foreign key in DB2?
- Increment varchar values on duplicate entry
- Auto increment considering Tenant id
- MySQL auto-increment based on group
- How to append an auto-incrementing value to a duplicate value?
- I need a MySql table column which need to reset to starting value
Related Questions in NEXTVAL
- How to insert rows with the serial column catching up from the largest value in the table in Postgres
- Dynamic table_name and nextval_sequence_name in PostgreSQL?
- How to get Oracle next sequence value in .NET Entity Framework?
- postgresql nextval generating existing values
- How to copy, change, and insert records in Postgres
- Get oracle sequenve next value without change it
- Oracle inserting with different position of attributes
- Is there way to add a field in a parent query that will increment as the query goes through all values generated in a subquery?
- rename sequence in other schema with same currval
- Sequence in create table?
- Find next unused ID in table SQL which has non continous ranges
- java.sql.SQLIntegrityConstraintViolationException: ORA-00001
- Retrieving CURRVAL and NEXTVAL in a single query
- postgresql alter table sequence id starting at a given value
- Hibernate ignores the schema name while calling nextval() - from postgres 12
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
SERIALis a syntax sugar around creating and using sequences.So you could do it all manually and create a special type of sequence that suits your needs:
Or if you already have a table and a
SERIALcolumn you could change the underlying sequence:The name of the underlying sequence could be retrieved by "describing" the table using psql: