protected static final int DB_TYPE_POSTGRESQL = 4;
protected static final int DB_TYPE_HIRDB = 5;
protected static final int DB_TYPE_UNKNOWN = -1;
- protected static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "MYSQL", "DB2", "POSTGRESQL", "HIRDB"};
- protected static final String [] DB_SQL_QUOTEDS = {"\"", "[", "`", "\"", "\"", "\""};
- protected static final String [] DB_SQL_QUOTEDE = {"\"", "]", "`", "\"", "\"", "\""};
- protected static final String [] SQL_TERMINATOR = {";" + System.getProperty("line.separator"), System.getProperty("line.separator") + "GO" + System.getProperty("line.separator"), ";" + System.getProperty("line.separator"), ";", ";", ";"};
- protected static final String [] SQL_PREFIX = {"@", ":r ", "source ", "", "", ""};
- protected static final String [] SQL_COMMENT_MARK = {"--", "--", "--", "--", "--", "--"};
+ protected static final String [] DB_TYPE_NAME = {
+ "ORACLE",
+ "SQLSERVER",
+ "MYSQL",
+ "DB2",
+ "POSTGRESQL",
+ "HIRDB"
+ };
+ protected static final String [] DB_SQL_QUOTEDS = {
+ "\"",
+ "[",
+ "`",
+ "\"",
+ "\"",
+ "\""
+ };
+ protected static final String [] DB_SQL_QUOTEDE = {
+ "\"",
+ "]",
+ "`",
+ "\"",
+ "\"",
+ "\""
+ };
+ protected static final String [] SQL_TERMINATOR = {
+ ";" + System.getProperty("line.separator"),
+ System.getProperty("line.separator") + "GO" + System.getProperty("line.separator"),
+ ";" + System.getProperty("line.separator"),
+ ";" + System.getProperty("line.separator"),
+ ";" + System.getProperty("line.separator"),
+ ";" + System.getProperty("line.separator")
+ };
+ protected static final String [] SQL_PREFIX = {
+ "@",
+ ":r ",
+ "source ",
+ "",
+ "",
+ ""
+ };
+ protected static final String [] SQL_COMMENT_MARK = {
+ "--",
+ "--",
+ "--",
+ "--",
+ "--",
+ "--"
+ };
+ protected static final String [] DROP_OPTION = {
+ " CASCADE CONSTRAINT PURGE",
+ "",
+ "",
+ "",
+ "",
+ ""
+ };
protected static final int MASK_PTN_ALL = 0;
protected static final int MASK_PTN_ALT = 1;
protected static final int MASK_PTN_EDGE = 2;
"OBJDEF",
"FKDEF"
};
- protected static final String [] DROP_OPTION = {" CASCADE CONSTRAINT PURGE", "", "", "", "", ""};
protected static final String [] SQL_FILE_NAME = {
"createTable.sql",
+ " and c.constraint_name = d.constraint_name"
+ " and a.r_owner = c.owner"
+ " and a.r_constraint_name = c.constraint_name"
+ + " and b.position = d.position"
+ " order by"
+ " a.table_name,a.constraint_name,b.position,d.position"
},
+ " and a.constraint_name = b.constraint_name "
+ " and b.referenced_table_name = c.table_name "
+ " and b.referenced_column_name = c.column_name "
+ + " and b.ordinal_position = c.ordinal_position"
+ },
+ { //DB2
+ "select "
+ + " a.tabname,"
+ + " replace(replace(a.remarks, chr(13), ''), chr(10), '') as table_comments, "
+ + " b.colname,"
+ + " replace(replace(b.remarks, chr(13), ''), chr(10), '') as column_comments, "
+ + " b.typename,"
+ + " b.length as data_length, "
+ + " b.length as data_precision, "
+ + " b.scale as data_scale, "
+ + " case b.nulls"
+ + " when 'N' then '\81Z'"
+ + " else null "
+ + " end as nullable,"
+ + " b.default as data_default "
+ + " from"
+ + " syscat.tables a,"
+ + " syscat.columns b"
+ + " where"
+ + " a.tabschema = current_schema"
+ + " and a.tabschema = b.tabschema"
+ + " and a.tabname = b.tabname"
+ + " and a.ownertype = 'U'"
+ + " and a.type = 'T'"
+ + " order by a.tabname,b.colno",
+ "select "
+ + " a.tabname as table_name,"
+ + " a.indname as index_name,"
+ + " '' as index_type,"
+ + " case a.uniquerule"
+ + " when 'P' then 'P'"
+ + " when 'U' then 'U'"
+ + " else null "
+ + " end as constraint_type,"
+ + " b.colname as column_name,"
+ + " b.colseq as column_position"
+ + " from"
+ + " syscat.indexes a,"
+ + " syscat.indexcoluse b"
+ + " where"
+ + " a.indschema = current_schema"
+ + " and a.indschema = b.indschema"
+ + " and a.indname = b.indname"
+ + " order by"
+ + " a.tabname,"
+ + " a.indname,"
+ + " b.colseq",
+ "select "
+ + " tabname as view_name,"
+ + " replace(replace(remarks, chr(13), ''), chr(10), '') as comments "
+ + " from"
+ + " syscat.tables "
+ + " where"
+ + " tabschema = current_schema"
+ + " and type='V' "
+ + " order by"
+ + " tabname",
+ "select "
+ + " routinename as object_name, "
+ + " case routinetype"
+ + " when 'F' then 'FUNCTION'"
+ + " when 'P' then 'PROCEDURE'"
+ + " end as object_type "
+ + " from "
+ + " syscat.routines "
+ + " where "
+ + " routineschema = current_schema "
+ + "union all "
+ + "select "
+ + " trigname as object_name, "
+ + " 'TRIGGER' as object_type "
+ + "from "
+ + " syscat.triggers "
+ + "where "
+ + " trigschema = current_schema "
+ + " order by object_name",
+ "select "
+ + " seqname as sequence_name,"
+ + " to_char(minvalue) as min_value,"
+ + " to_char(maxvalue) as max_value,"
+ + " to_char(increment) as increment_by,"
+ + " cycle as cycle_flag,"
+ + " order as order_flag,"
+ + " to_char(cache) as cache_size,"
+ + " to_char(nextcachefirstvalue) as last_number "
+ + " from syscat.sequences "
+ + " where "
+ + " seqschema = current_schema "
+ + " order by seqname",
+ "select "
+ + " tabname as synonym_name,"
+ + " base_tabschema as table_owner,"
+ + " base_tabname as table_name,"
+ + " '' as db_link "
+ + "from syscat.tables "
+ + " where type = 'A' "
+ + " and ownertype = 'U'"
+ + " and tabschema = current_schema "
+ + "order by synonym_name,table_owner,table_name",
+ "",
+ "select distinct "
+ + " a.tabname as table_name, "
+ + " a.constname as constraint_name, "
+ + " b.colname as column_name, "
+ + " b.colseq as position,"
+ + " c.tabname as r_table_name, "
+ + " c.colname as r_column_name, "
+ + " c.colseq as r_position "
+ + " from "
+ + " syscat.references a, "
+ + " syscat.keycoluse b,"
+ + " syscat.keycoluse c"
+ + " where "
+ + " a.tabschema = current_schema"
+ + " and a.constname = b.constname"
+ + " and a.tabschema = b.tabschema"
+ + " and a.tabname = b.tabname"
+ + " and a.refkeyname = c.constname"
+ + " and a.reftabschema = c.tabschema"
+ + " and a.reftabname = c.tabname"
+ + " and b.colseq = c.colseq"
+ + " order by"
+ + " a.tabname,a.constname,b.colseq,c.colseq"
}
};
protected static String sql_view_text[] = {
+ "inner join sys.sql_modules c "
+ "on c.object_id = b.object_id "
+ "where a.name = ?",
- "select view_definition from information_schema.views where table_name = ?"
+ "select view_definition from information_schema.views where table_name = ?",
+ "select text from syscat.views where viewname= ?"
};
protected static String sql_view_column_and_comment[] = {
"select "
+ " information_schema.columns "
+ " where"
+ " table_name = ? "
- + " order by ordinal_position"
+ + " order by ordinal_position",
+ "select "
+ + " colname as column_name,"
+ + " replace(replace(remarks, chr(13), ''), chr(10), '') as column_comments "
+ + " from"
+ + " syscat.columns "
+ + " where"
+ + " tabschema = current_schema"
+ + " and tabname = ?"
+ + " order by colno"
};
protected static String sql_proc[] = {
"select text from user_source where type = ? and name = ? order by line",
+ ") a "
+ "where "
+ " a.object_type = ? "
+ + " and a.object_name = ? ",
+ "select "
+ + " a.definition "
+ + " from "
+ + "( "
+ + "select "
+ + " routinename as object_name, "
+ + " case routinetype"
+ + " when 'F' then 'FUNCTION'"
+ + " when 'P' then 'PROCEDURE'"
+ + " end as object_type, "
+ + " text as definition "
+ + " from "
+ + " syscat.routines "
+ + " where "
+ + " routineschema = current_schema "
+ + "union all "
+ + "select "
+ + " trigname as object_name, "
+ + " 'TRIGGER' as object_type, "
+ + " text as definition "
+ + "from "
+ + " syscat.triggers "
+ + "where "
+ + " trigschema = current_schema "
+ + ") a "
+ + "where "
+ + " a.object_type = ? "
+ " and a.object_name = ? "
};