use of org.jooq.meta.postgres.information_schema.tables.KeyColumnUsage in project jOOQ by jOOQ.
the class PostgresDatabase method keys.
private ResultQuery<Record6<String, String, String, String, String, Integer>> keys(List<String> schemas, Field<String> constraintType) {
KeyColumnUsage k = KEY_COLUMN_USAGE.as("k");
PgConstraint c = PG_CONSTRAINT.as("c");
return create().select(k.TABLE_CATALOG, k.TABLE_SCHEMA, k.TABLE_NAME, k.CONSTRAINT_NAME, k.COLUMN_NAME, k.ORDINAL_POSITION).from(c).join(k).on(k.TABLE_SCHEMA.eq(c.pgClass().pgNamespace().NSPNAME)).and(k.TABLE_NAME.eq(c.pgClass().RELNAME)).and(k.CONSTRAINT_SCHEMA.eq(c.pgNamespace().NSPNAME)).and(k.CONSTRAINT_NAME.eq(c.CONNAME)).where(c.CONTYPE.eq(constraintType)).and(c.pgNamespace().NSPNAME.in(schemas)).orderBy(k.TABLE_SCHEMA.asc(), k.TABLE_NAME.asc(), k.CONSTRAINT_NAME.asc(), k.ORDINAL_POSITION.asc());
}
Aggregations