snippetMinor
Is it possible to create an alias/shortcut/makro/function for a collection of keywords?
Viewed 0 times
createshortcutfunctioncollectionpossibleforkeywordsaliasmakro
Problem
In Oracle 12c, it's possible to use
Is it possible to create an alias/shortcut/makro/function to get Oracle to treat
AUTO_INCREMENT functionality by using the keywords/phrase GENERATED ALWAYS AS IDENTITY. This seems cumbersome/clunky to me, given that in other dialects of SQL that I'm used to (SQLite, MySQL), the same is achieved with the keyword AUTO_INCREMENT or AUTOINCREMENT.Is it possible to create an alias/shortcut/makro/function to get Oracle to treat
AUTO_INCREMENT as meaning the same as GENERATED ALWAYS AS IDENTITY? (I'm not proposing editing the source code as a practical solution. I'd rather submit a feature request.)Solution
You can tell the tool, in this case SQL Developer, to do it for you.
I talk about how to set this up here
https://www.thatjeffsmith.com/archive/2014/02/auto-replace-in-oracle-sql-developer/
But basically, you define a code template in the preferences with the code you want to be recognized as a template, and then the code you want inserted.
If there is only one match for your template, when you invoke it with ctrl+spacebar, it automatically inserts the code.
If there are multiple matches, it prompts you for what you want.
I built two, one for
You could of course submit an enhancement request for the database so this keyword would be honored, but that's a years long process, assuming it even gets accepted and implemented.
I talk about how to set this up here
https://www.thatjeffsmith.com/archive/2014/02/auto-replace-in-oracle-sql-developer/
But basically, you define a code template in the preferences with the code you want to be recognized as a template, and then the code you want inserted.
If there is only one match for your template, when you invoke it with ctrl+spacebar, it automatically inserts the code.
If there are multiple matches, it prompts you for what you want.
I built two, one for
- auto_increment - long form
- autoincrement - short form
You could of course submit an enhancement request for the database so this keyword would be honored, but that's a years long process, assuming it even gets accepted and implemented.
Context
StackExchange Database Administrators Q#212140, answer score: 9
Revisions (0)
No revisions yet.