Simple Type Alias ​​- Best Practices for Oracle

I have a DB with multiple oracle schemas in which the client account must be varchar (50) in all schemas. Therefore, I would like to assign a new name to varchar (50), such as MYCLIENT, such that in the whole table, sp and functions, I just use MYCLIENT to define the field, parameter, etc., to avoid misunderstandings.

1 - How to define a new type in Oracle (Simplest Method)

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

thanks a lot

+6
source share
1 answer

I am afraid that there is no easy way to achieve this. You can define a subtype inside a package as follows:

SUBTYPE myclient is VARCHAR2(50); 

but you cannot use this as a type column for a database. To do this, you will need to determine the type of SQL using:

 CREATE TYPE myclient ... 

but you can define record types, object types, or collection types this way. This is strange, but good, just like in Oracle ... :)

+5
source

Source: https://habr.com/ru/post/957250/


All Articles