Skip to content
Advertisement

Can I combine parts of multiple columns in Oracle SQL

I’m a student in college and I’m working on a project with Oracle DB. I was wondering if it was possible to make a column value appear as concatenated parts of other columns when I Insert a line and use that column as PK ?

So on a table like this :

So when I insert a line I’d like the id to be set automatically to a concatenated value of the first 3 character of the maker, the first 3 of the range, the first 3 of the model, the ram and the color.

For example :

The id that would be generated is SAMGALS1032BLK.

Is it possible to do that? If not is there something that could look like that, maybe with a SELECT statement when I want to show the table?

Advertisement

Answer

You can try this:

https://dbfiddle.uk/?rdbms=oracle_11.2&fiddle=954fb222fba8a2b49c3937c47e9f4726

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement