Вот один из вариантов как это сделать:
declare v_text varchar2(32767); procedure print(p_msg in varchar2) is v_msg varchar2(32767); begin v_msg := p_msg; if length(v_msg) <= 255 then dbms_output.put_line(v_msg); else while length(v_msg) > 0 loop dbms_output.put_line(substr(v_msg, 1, 255)); v_msg := substr(v_msg, 256); end loop; end if; end print; begin v_text := dbms_lob.substr(lob_loc => DBMS_METADATA.GET_DDL('TABLE', 'EMPLOYEE', 'SCOTT'), amount => 32767, offset => 1); print(v_text); end;
Результат:
CREATE TABLE "SCOTT"."EMPLOYEE" ( "EMPLOYEE_ID" NUMBER(4,0), "LAST_NAME" VARCHAR2(15), "FIRST_NAME" VARCHAR2(15), "MIDDLE_INITIAL" VARCHAR2(1), "JOB_ID" NUMBER(3,0), "MANAGER_ID" NUMBER(4,0), "HIRE_DATE" DATE, "SALARY" NUMBER(7,2), "COMMISSION" NUMBER(7,2), "DEPARTMENT_ID" NUMBER(2,0), PRIMARY KEY ("EMPLOYEE_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "MAIN" ENABLE, CHECK (EMPLOYEE_ID IS NOT NULL) ENABLE, CHECK (DEPARTMENT_ID IS NOT NULL) ENABLE, FOREIGN KEY ("JOB_ID") REFERENCES "SCOTT"."JOB" ("JOB_ID") ENABLE, FOREIGN KEY ("MANAGER_ID") REFERENCES "SCOTT"."EMPLOYEE" ("EMPLOYEE_ID") ENABLE, FOREIGN KEY ("DEPARTMENT_ID") REFERENCES "SCOTT"."DEPARTMENT" ("DEPARTMENT_ID") ENABLE ) 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) TABLESPACE "MAIN"
Спасибо нужный скрипт.
ОтветитьУдалить