Reputation: 2755
Is it possible to create a "type synonym" in oracle? Something like:
CREATE PUBLIC SYNONYM EmailType FOR VARCHAR2(120);
Upvotes: 4
Views: 2718
Reputation: 928
You cannot do that, but you might want to use SUBTYPE. Place SUBTYPE declaration inside of package and use that.
CREATE OR REPLACE PACKAGE SUBTYPES_PKG IS
SUBTYPE EMAIL IS VARCHAR2(120);
END;
Upvotes: 4
Reputation: 52863
I don't have access to a database at the moment, so I'll check in the morning but I'm fairly sure you can do this. Although you can't create an object as a public synonym, you can create a synonym on almost any object.
CREATE OR REPLACE TYPE EmailType AS OBJECT( EMail VARCHAR2(120));
create or replace public synonym emailtype for emailtype;
Upvotes: 0
Reputation: 50017
What you're looking for is known in other databases as a "domain" - and there ain't no domains in Oracle. Sorry for the bad news. To use a TYPE in Oracle you'll need something like
CREATE OR REPLACE TYPE EMAILTYPE AS OBJECT
(
strEmail VARCHAR2(120)
)
and then you'll probably need to define constructors and methods to operate on your type.
Share and enjoy.
Upvotes: 2