我要从现有表生成create query(ddl)的几个表,并从oracle转换为与postgres兼容的表。
答案 0 :(得分:1)
可以通过执行DBMS_METADATA.GET_DDL
来获取DDL,例如在本示例中:
SQL> set long 10000
SQL> set pagesize 0
SQL>
SQL> select dbms_metadata.get_ddl('TABLE', 'EMP', 'SCOTT') from dual;
CREATE TABLE "SCOTT"."EMP"
( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
"ENAME" VARCHAR2(10),
"JOB" VARCHAR2(9),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"COMM" NUMBER(7,2),
"DEPTNO" NUMBER(2,0),
CONSTRAINT "FK_EMP_DEPT" FOREIGN KEY ("DEPTNO")
REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USER_DATA"
SQL>
不过,我不知道如何将其转换为Postgres(更不用说使用Java 了。)