":r ",
"source ",
"",
- "",
+ "\\i ",
""
};
protected static final String [] SQL_COMMENT_MARK = {
+ " a.table_name,"
+ " replace(replace(a.table_comment, char(13), ''), char(10), '') as table_comments, "
+ " b.column_name,"
- + " replace(replace(b.column_comment, char(13), ''), char(10), '') as column_comment, "
- + " b.column_type,"
- + " b.character_maximum_length as data_precision,"
+ + " replace(replace(b.column_comment, char(13), ''), char(10), '') as column_comments, "
+ + " b.column_type as data_type,"
+ + " b.character_maximum_length as data_length,"
+ " b.numeric_precision as data_precision,"
+ " b.numeric_scale as data_scale,"
+ " case b.is_nullable"
+ " 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.typename as data_type,"
+ " b.length as data_length, "
+ " b.length as data_precision, "
+ " b.scale as data_scale, "
+ " and b.colseq = c.colseq"
+ " order by"
+ " a.tabname,a.constname,b.colseq,c.colseq"
+ },
+ { //PostgreSQL
+ "select "
+ + " a.table_name,"
+ + " e.description as table_comments,"
+ + " b.column_name,"
+ + " f.description as column_comments,"
+ + " data_type,"
+ + " b.character_maximum_length as data_length,"
+ + " b.numeric_precision as data_precision,"
+ + " b.numeric_scale as data_scale,"
+ + " case b.is_nullable"
+ + " when 'NO' then '\81Z'"
+ + " else null "
+ + " end as nullable,"
+ + " b.column_default as data_default "
+ + " from "
+ + " information_schema.tables a,"
+ + " information_schema.columns b,"
+ + " pg_stat_user_tables c"
+ + " left outer join pg_description e"
+ + " on c.relid=e.objoid and e.objsubid=0,"
+ + " pg_attribute d"
+ + " left outer join pg_description f"
+ + " on f.objoid=d.attrelid and f.objsubid=d.attnum"
+ + " where "
+ + " a.table_schema = current_schema()"
+ + " and a.table_type = 'BASE TABLE'"
+ + " and a.table_schema = b.table_schema "
+ + " and a.table_name = b.table_name "
+ + " and a.table_schema = c.schemaname "
+ + " and a.table_name = c.relname"
+ + " and c.relid = d.attrelid"
+ + " and b.column_name = d.attname"
+ + " order by a.table_name,b.ordinal_position",
+ "select "
+ + " a.table_name, "
+ + " b.constraint_name as index_name,"
+ + " ''::text as index_type, "
+ + " case b.constraint_type "
+ + " when 'PRIMARY KEY' then 'P' "
+ + " when 'UNIQUE' then 'U' "
+ + " end as constraint_type,"
+ + " c.column_name,"
+ + " c.ordinal_position as column_position"
+ + " from"
+ + " information_schema.tables a,"
+ + " information_schema.table_constraints b,"
+ + " information_schema.key_column_usage c"
+ + " where"
+ + " a.table_schema = current_schema()"
+ + " and a.table_type = 'BASE TABLE'"
+ + " and a.table_schema = b.table_schema"
+ + " and a.table_name = b.table_name"
+ + " and b.table_schema = c.table_schema"
+ + " and b.table_name = c.table_name"
+ + " and b.constraint_name = c.constraint_name"
+ + " and b.constraint_type in('PRIMARY KEY','UNIQUE')"
+ + " union select"
+ + " e.tablename::text as table_name,"
+ + " e.indexname::text as index_name,"
+ + " ''::text as index_type,"
+ + " ''::text as constraint_type,"
+ + " f.column_name,"
+ + " e.column_position"
+ + " from"
+ + " ("
+ + " select"
+ + " d.schemaname,"
+ + " d.tablename,"
+ + " d.indexname,"
+ + " d.indkey,"
+ + " row_number() over() as column_position"
+ + " from"
+ + " ("
+ + " select"
+ + " a.schemaname,"
+ + " a.tablename,"
+ + " a.indexname,"
+ + " unnest(string_to_array(c.indkey::text, ' '))::int indkey"
+ + " from"
+ + " pg_indexes a,"
+ + " pg_stat_user_indexes b,"
+ + " pg_index c"
+ + " where"
+ + " a.schemaname = current_schema()"
+ + " and a.schemaname = b.schemaname"
+ + " and a.tablename = b.relname"
+ + " and a.indexname = b.indexrelname"
+ + " and b.relid = c.indrelid"
+ + " and b.indexrelid = c.indexrelid"
+ + " and c.indisunique = false"
+ + " and c.indisprimary = false"
+ + " ) d"
+ + " ) e,"
+ + " information_schema.columns f"
+ + " where "
+ + " e.schemaname = current_schema()"
+ + " and e.schemaname = f.table_schema"
+ + " and e.tablename = f.table_name"
+ + " and e.indkey = f.ordinal_position"
+ + " order by table_name,index_name,column_position",
+ "select "
+ + " a.table_name as view_name, "
+ + " ''::text as comments "
+ + "from "
+ + " information_schema.views a "
+ + " where"
+ + " table_schema = current_schema()"
+ + " order by "
+ + " a.table_name",
+ "select "
+ + " routine_name as object_name, "
+ + " routine_type as object_type, "
+ + " '' as action_timing, "
+ + " '' as event_action, "
+ + " '' as event_object "
+ + " from "
+ + " information_schema.routines "
+ + " where"
+ + " routine_schema = current_schema()"
+ + " and (routine_type = 'PROCEDURE' or routine_type = 'FUNCTION') "
+ + " union select "
+ + " trigger_name as object_name, "
+ + " 'TRIGGER' as object_type, "
+ + " action_timing as action_timing, "
+ + " event_manipulation as event_action, "
+ + " event_object_table as event_object "
+ + " from "
+ + " information_schema.triggers "
+ + " where"
+ + " trigger_schema = current_schema()"
+ + " order by object_name,object_type ",
+ "",
+ "",
+ "",
+ "select "
+ + " a.table_name,"
+ + " a.constraint_name,"
+ + " c.column_name,"
+ + " d.table_name as r_table_name,"
+ + " e.column_name as r_column_name,"
+ + " f.ordinal_position as position,"
+ + " g.ordinal_position as r_position"
+ + " from"
+ + " information_schema.table_constraints a,"
+ + " information_schema.referential_constraints b,"
+ + " information_schema.constraint_column_usage c,"
+ + " information_schema.table_constraints d,"
+ + " information_schema.constraint_column_usage e,"
+ + " information_schema.columns f,"
+ + " information_schema.columns g"
+ + " where "
+ + " a.constraint_schema = current_schema()"
+ + " and a.constraint_schema = b.constraint_schema"
+ + " and a.constraint_schema = c.constraint_schema"
+ + " and a.constraint_name = b.constraint_name"
+ + " and a.constraint_name = c.constraint_name"
+ + " and a.constraint_type = 'FOREIGN KEY'"
+ + " and b.constraint_schema = d.constraint_schema"
+ + " and b.unique_constraint_name = d.constraint_name"
+ + " and d.constraint_schema = e.constraint_schema"
+ + " and d.constraint_name = e.constraint_name"
+ + " and a.table_schema = f.table_schema"
+ + " and c.table_name = f.table_name"
+ + " and c.column_name = f.column_name"
+ + " and e.table_name = g.table_name"
+ + " and e.column_name = g.column_name"
}
};
protected static String sql_view_text[] = {
+ "on c.object_id = b.object_id "
+ "where a.name = ?",
"select view_definition from information_schema.views where table_name = ?",
- "select text from syscat.views where viewname= ?"
+ "select text from syscat.views where viewname= ?",
+ "select view_definition from information_schema.views where table_name = ?"
};
protected static String sql_view_column_and_comment[] = {
"select "
+ " where"
+ " tabschema = current_schema"
+ " and tabname = ?"
- + " order by colno"
+ + " order by colno",
+ " select "
+ + " column_name,"
+ + " ''::text as column_comment "
+ + " from"
+ + " information_schema.columns "
+ + " where"
+ + " table_name = ? "
+ + " order by ordinal_position"
};
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 "
+ + " routine_name as object_name, "
+ + " routine_type as object_type, "
+ + " routine_definition as definition "
+ + "from "
+ + " information_schema.routines "
+ + "where "
+ + " routine_schema = current_schema() "
+ + "union select "
+ + " trigger_name as object_name, "
+ + " 'TRIGGER' as object_type, "
+ + " action_statement as definition "
+ + "from "
+ + " information_schema.triggers "
+ + "where "
+ + " trigger_schema = current_schema() "
+ + ") a "
+ + "where "
+ + " a.object_type = ? "
+ " and a.object_name = ? "
};