return"select column_name AS COLNAME, ordinal_position AS COLPOSITION, column_default AS DATADEFAULT, is_nullable AS NULLABLE, data_type AS DATATYPE, "+
"character_maximum_length AS DATALENGTH, numeric_precision AS DATAPRECISION, numeric_scale AS DATASCALE, column_key AS COLKEY, column_comment AS COLCOMMENT "+
"from information_schema.columns where table_schema = '"+dbName+"' and table_name = '"+tableName+"' ";
"from information_schema.columns where table_schema = '"+dbName+"' and table_name = '"+tableName+"' order by ordinal_position ";
return"select columns.column_name AS colName, columns.data_type AS DATATYPE, columns.data_length AS DATALENGTH, columns.data_precision AS DATAPRECISION, "+
"columns.data_scale AS DATASCALE, columns.nullable AS NULLABLE, columns.column_id AS COLPOSITION, columns.data_default AS DATADEFAULT, comments.comments AS COLCOMMENT "+
"columns.data_scale AS DATASCALE, columns.nullable AS NULLABLE, columns.column_id AS COLPOSITION, columns.data_default AS DATADEFAULT, comments.comments AS COLCOMMENT,"+
"case when t.column_name is null then 0 else 1 end as COLKEY "+
"from sys.dba_tab_columns columns LEFT JOIN sys.dba_col_comments comments ON columns.owner = comments.owner AND columns.table_name = comments.table_name AND columns.column_name = comments.column_name "+
"where columns.owner = UPPER('"+dbName+"') and columns.table_name = UPPER('"+tableName+"')";
"left join ( "+
"select col.column_name as column_name, con.table_name as table_name from user_constraints con, user_cons_columns col "+
"where con.constraint_name = col.constraint_name and con.constraint_type = 'P' "+
") t on t.table_name = columns.table_name and columns.column_name = t.column_name"+
"where columns.owner = UPPER('"+dbName+"') and columns.table_name = UPPER('"+tableName+"') order by columns.column_id ";
}
@Override
...
...
@@ -44,12 +50,12 @@ public class OracleDialect extends AbstractDbDialect {
return"select columns.name AS colName, columns.column_id AS COLPOSITION, columns.max_length AS DATALENGTH, columns.precision AS DATAPRECISION, columns.scale AS DATASCALE, "+
"columns.is_nullable AS NULLABLE, types.name AS DATATYPE, properties.value AS COLCOMMENT, e.text AS DATADEFAULT "+
"columns.is_nullable AS NULLABLE, types.name AS DATATYPE, CAST(ep.value AS NVARCHAR(128)) AS COLCOMMENT, e.text AS DATADEFAULT, "+
"(select top 1 ind.is_primary_key from sys.index_columns ic left join sys.indexes ind on ic.object_id = ind.object_id and ic.index_id = ind.index_id and ind.name like 'PK_%' where ic.object_id=columns.object_id and ic.column_id=columns.column_id) AS COLKEY "+
"from sys.columns columns LEFT JOIN sys.types types ON columns.system_type_id = types.system_type_id "+
"LEFT JOIN syscomments e ON columns.default_object_id= e.id "+
"LEFT JOIN sys.extended_properties properties ON properties.major_id = columns.object_id AND properties.minor_id = columns.column_id "+