patternsqlMinor
What is the data type of 'emp::regclass'?
Viewed 0 times
thewhatempregclasstypedata
Problem
There is this question that is important to answer.
I tend to think that since 'regclass' is an alias for OID the answer is 'OID'.
Am I right here?
Help will be appreciated
I tend to think that since 'regclass' is an alias for OID the answer is 'OID'.
Am I right here?
Help will be appreciated
Solution
regclass and the other reg types are "object identifier types". As the documentation says:The
oid type is currently implemented as an unsigned four-byte integer.[...]
The OID alias types have no operations of their own except for specialized input and output routines. These routines are able to accept and display symbolic names for system objects, rather than the raw numeric value that type
oid would use.So it is just a convenience: it really is the numeric object ID, but is displayed as the object name.
regclass can be cast to numerical data types: then it will become the oid value.regclass can also be cast to text: then it will become the table name.Context
StackExchange Database Administrators Q#299177, answer score: 4
Revisions (0)
No revisions yet.