I need to create an ID that uses data from the user's input. For example, the first letter is "M" the second is the year of birth that the user inputs, then the two first characters of the province the user lives in (for example, ON for Ontario), and then a sequence of random numbers. Like this: M-1990-ON-0001 Do you have any idea how I can do that?
Customized ID in PostgreSQL using the user's input
62 Views Asked by Melika02 At
1
There are 1 best solutions below
Related Questions in POSTGRESQL
- Only the first SQL script gets executed inside Docker Postgres container
- Compare fields in two tables
- Hibernate ClobJdbcType bindings: what are the diferences?
- Postgres && statement Error in Mybatis Mapper?
- Can this query be optimized? (Choosing a random row to insert, that excludes previously inserted Rows)
- Connection terminated unexpectedly while performing multi row insert using pg-promise
- Processing multiple forms in nodejs and postgresql
- How to copy data from SQLite to postgreSQL?
- PGAdmin4 configured behind a reverse proxy but unable to connect to Postgresql server
- Updates to pgsodium encrypted values don't use specified key_id
- Connecting to Postgres running in a Docker container using psql
- Can't connect to local postgresql server from my docker container
- Django Arrayfield migration to cloud sql (Postgresql) not creating the column
- Get list of matching keywords for each post
- docker-compose can't reset postgresql database
Related Questions in PRIMARY-KEY
- Claves combinadas
- Postgresql Primary Key Index Maintenance
- "Number of referencing columns in foreign key differs from number of referenced columns" inline error
- Entity Framework Core 7 - configuring two keys
- Create a flexible key for merge in R
- Record versioning and approving changes TypeOrm postgres
- Primary key issue of a table imported from CSV, using MySQL Workbench (Linux Mint 21 Vanessa)
- Why Hibernate now uses TABLE strategy as default for MySQL?
- how to make a django model with no id column and primary key?
- CockroachDB: The best way to turn a UNIQUE CONSTRAINT into a PRIMARY KEY?
- Alter entries of Primary key in table to match number of rows from COUNT Postgresql
- How to update a part of primary key if it is a combination of three columns
- Is it wise to construct a custom string (combination of entity, year and alphanumeric) to have as a primary key for a postgres database in Django?
- Django filtering with Custom primary key
- TypeORM joins by multiple PrimaryColumns ignoring defined JoinColumn
Related Questions in CUSTOMIZING
- Customizing Divi Blog module for ACF
- create modules and directories by custom spring initializer
- CSS scrollbar-gutter
- Module "ag-grid-angular" has no exported member 'AgGridThemeOverrideService'
- How to customise alert events in Firebase Crashlytics
- How to make a JFileChooser with a different language?
- Customized ID in PostgreSQL using the user's input
- How can I rename builtin functions e.g "if" -> "hehe", "elif" -> "haha", "else" -> "hihi"?
- vuetify.js doesn't working in Vue 3 (theme customzing)
- Overwrite a function in a python library
- Is it possible to change the default flags in tmux window-format?
- Migration of custom Module from Odoo 13 to 15
- Odoo Customizing : Many2one field in contacts view, which shows only the Individuals of the currently displayed Company
- How to customize file_picker UI in flutter
- How to customixe React-Native verification Code
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?
You can do that as a generated column. ie:
However, you should never make such info a primary key. Just use a key for yourself but do not as a primary key.
DBFiddle demo
If you think about it such a value wouldn't be even unique (same province, same year, two persons for example).