我想知道在 postgresql 8.4 中是否可以进行 oracle 风格的面向对象编程。我已经安装了 orafce。当我尝试创建一个对象时,如下所示:
CREATE TYPE addr_obj_typ AS OBJECT (
street VARCHAR2(30),
city VARCHAR2(20),
state CHAR(2),
zip NUMBER(5));
我得到了这个错误:
ERROR: syntax error at or near "object"
LINE 1: create type addr_obj_typ as object
答案1
像这样吗?
CREATE DOMAIN zipcode AS
INT CHECK(VALUE < 99999)
;
CREATE TYPE addr_obj_typ AS (
street VARCHAR(30),
city VARCHAR(20),
state CHAR(2),
zip zipcode
);
SELECT
CAST(('a','b','c','90210') AS addr_obj_typ);