1、根据数据库获取所有表名sql
/**
* 根据数据库获取所有表名sql
* @param schema
* @param databaseType
* @return sql
*/
public static String getTableNames(String schema, String databaseType){
if (StringUtils.isEmpty(schema) || StringUtils.isEmpty(databaseType)) {
return null;
}
String sql = null;
if ("ORACLE".equals(databaseType.toUpperCase(Locale.ROOT))) {
sql = "SELECT TABLE_NAME as TABLE_NAME FROM USER_TABLES";
} else if ("DB2".equals(databaseType.toUpperCase(Locale.ROOT))) {
sql = "select tabname as TABLE_NAME from syscat.tables where tabschema='"+ schema +"'";
} else if ("MYSQL".equals(databaseType.toUpperCase(Locale.ROOT))) {
sql = "select table_name as TABLE_NAME from information_schema.tables where table_schema='"+ schema +"' and table_type='base table'";
}
return sql;
}