问题1: 当然可以
我机器上可以同时跑SQL Server, Oracle, DB2, MySQL
问题2:
建表:
create table test(id int primary key, col2 varchar2(32));
存储过程:
--get the table DDL
CREATE OR REPLACE FUNCTION get_table_md (schemaName in VARCHAR2, tableName in VARCHAR2)
RETURN CLOB IS
-- Define local variables.
h NUMBER; --handle returned by OPEN
th NUMBER; -- handle returned by ADD_TRANSFORM
doc CLOB;
BEGIN
-- Specify the object type.
h := DBMS_METADATA.OPEN('TABLE');
-- Use filters to specify the particular object desired.
--schemaName := upper(schemaName);
--tableName := upper(tableName);
DBMS_METADATA.SET_FILTER(h,'SCHEMA',upper(schemaName));
DBMS_METADATA.SET_FILTER(h,'NAME',upper(tableName));
-- Request that the metadata be transformed into creation DDL.
th := DBMS_METADATA.ADD_TRANSFORM(h,'DDL');
-- Fetch the object.
doc := DBMS_METADATA.FETCH_CLOB(h);