Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple type alias - Best practice for Oracle

I have a multi-schema oracle DB in which client account should be varchar(50) in all the schemas. Therefore, I'd like to assign a new name to varchar(50) like MYCLIENT such that in all table, sp and functions, I simply use MYCLIENT to define a field, parameter, etc. to avoid misintegrity.

1 - How should I define the new type in Oracle (The simplest method)

2 - Where to define it (Schema, package, DB, ..) in accordance to the best practices?

Thanks a lot

like image 292
Hosm Avatar asked Nov 02 '13 13:11

Hosm


1 Answers

I'm afraid there's no simple way to achieve this. You could define a subtype inside a package like this:

SUBTYPE myclient is VARCHAR2(50);

but you would not be able to use this as a type for database column. In order to do so, you would have to define a SQL type with:

CREATE TYPE myclient ...

but you are only able to define record types, object types or collection types this way. This is weird, but well, just as quite a few things in Oracle... :)

like image 151
Kombajn zbożowy Avatar answered Oct 03 '22 04:10

Kombajn zbożowy