0
# Schema Structure Discovery
1
2
Complete schema exploration including catalogs, schemas, tables, and views with comprehensive metadata extraction across all database objects.
3
4
## Capabilities
5
6
### Catalog Operations
7
8
Database catalog discovery and navigation for multi-catalog database systems.
9
10
```java { .api }
11
/**
12
* Gets all catalogs in the database
13
* @returns List of catalog definitions
14
*/
15
List<CatalogDefinition> getCatalogs();
16
17
/**
18
* Gets a specific catalog by name
19
* @param name - Catalog name to lookup
20
* @returns Catalog definition or null if not found
21
*/
22
CatalogDefinition getCatalog(String name);
23
24
/**
25
* Gets configured input catalog names
26
* @returns List of input catalog names from configuration
27
*/
28
List<String> getInputCatalogs();
29
```
30
31
**Usage Examples:**
32
33
```java
34
import org.jooq.meta.Database;
35
import org.jooq.meta.CatalogDefinition;
36
37
// Get all catalogs
38
List<CatalogDefinition> catalogs = database.getCatalogs();
39
for (CatalogDefinition catalog : catalogs) {
40
System.out.println("Catalog: " + catalog.getName());
41
}
42
43
// Get specific catalog
44
CatalogDefinition catalog = database.getCatalog("production_db");
45
if (catalog != null) {
46
System.out.println("Found catalog: " + catalog.getQualifiedName());
47
}
48
```
49
50
### Schema Operations
51
52
Schema discovery and navigation within catalogs or across the entire database.
53
54
```java { .api }
55
/**
56
* Gets all schemas across all catalogs
57
* @returns List of all schema definitions
58
*/
59
List<SchemaDefinition> getSchemata();
60
61
/**
62
* Gets schemas within a specific catalog
63
* @param catalog - Catalog to search within
64
* @returns List of schema definitions in the catalog
65
*/
66
List<SchemaDefinition> getSchemata(CatalogDefinition catalog);
67
68
/**
69
* Gets a specific schema by name
70
* @param name - Schema name to lookup
71
* @returns Schema definition or null if not found
72
*/
73
SchemaDefinition getSchema(String name);
74
75
/**
76
* Gets configured input schema names
77
* @returns List of input schema names from configuration
78
*/
79
List<String> getInputSchemata();
80
81
/**
82
* Gets input schema names for a specific catalog
83
* @param catalog - Catalog definition
84
* @returns List of input schema names in the catalog
85
*/
86
List<String> getInputSchemata(CatalogDefinition catalog);
87
88
/**
89
* Gets input schema names for a specific catalog by name
90
* @param catalog - Catalog name
91
* @returns List of input schema names in the catalog
92
*/
93
List<String> getInputSchemata(String catalog);
94
```
95
96
**Usage Examples:**
97
98
```java
99
import org.jooq.meta.Database;
100
import org.jooq.meta.SchemaDefinition;
101
import org.jooq.meta.CatalogDefinition;
102
103
// Get all schemas
104
List<SchemaDefinition> schemas = database.getSchemata();
105
for (SchemaDefinition schema : schemas) {
106
System.out.println("Schema: " + schema.getQualifiedName());
107
System.out.println("Comment: " + schema.getComment());
108
}
109
110
// Get schemas in specific catalog
111
CatalogDefinition catalog = database.getCatalog("mydb");
112
List<SchemaDefinition> catalogSchemas = database.getSchemata(catalog);
113
114
// Get specific schema
115
SchemaDefinition publicSchema = database.getSchema("public");
116
```
117
118
### Table Discovery
119
120
Comprehensive table and view discovery with filtering and navigation capabilities.
121
122
```java { .api }
123
/**
124
* Gets all tables across all schemas
125
* @returns List of all table definitions
126
*/
127
List<TableDefinition> getTables();
128
129
/**
130
* Gets tables within a specific schema
131
* @param schema - Schema to search within
132
* @returns List of table definitions in the schema
133
*/
134
List<TableDefinition> getTables(SchemaDefinition schema);
135
136
/**
137
* Gets a specific table by schema and name
138
* @param schema - Schema containing the table
139
* @param name - Table name to lookup
140
* @returns Table definition or null if not found
141
*/
142
TableDefinition getTable(SchemaDefinition schema, String name);
143
144
/**
145
* Gets a specific table with case sensitivity control
146
* @param schema - Schema containing the table
147
* @param name - Table name to lookup
148
* @param ignoreCase - Whether to ignore case in name matching
149
* @returns Table definition or null if not found
150
*/
151
TableDefinition getTable(SchemaDefinition schema, String name, boolean ignoreCase);
152
153
/**
154
* Gets a specific table by schema and jOOQ Name
155
* @param schema - Schema containing the table
156
* @param name - jOOQ Name object for the table
157
* @returns Table definition or null if not found
158
*/
159
TableDefinition getTable(SchemaDefinition schema, Name name);
160
161
/**
162
* Gets a specific table by jOOQ Name with case sensitivity control
163
* @param schema - Schema containing the table
164
* @param name - jOOQ Name object for the table
165
* @param ignoreCase - Whether to ignore case in name matching
166
* @returns Table definition or null if not found
167
*/
168
TableDefinition getTable(SchemaDefinition schema, Name name, boolean ignoreCase);
169
```
170
171
**Usage Examples:**
172
173
```java
174
import org.jooq.meta.Database;
175
import org.jooq.meta.TableDefinition;
176
import org.jooq.meta.SchemaDefinition;
177
import org.jooq.Name;
178
import org.jooq.impl.DSL;
179
180
// Get all tables
181
List<TableDefinition> allTables = database.getTables();
182
System.out.println("Total tables: " + allTables.size());
183
184
// Get tables in specific schema
185
SchemaDefinition schema = database.getSchema("public");
186
List<TableDefinition> schemaTables = database.getTables(schema);
187
188
for (TableDefinition table : schemaTables) {
189
System.out.println("Table: " + table.getName());
190
System.out.println("Type: " + (table.isView() ? "VIEW" : "TABLE"));
191
System.out.println("Columns: " + table.getColumns().size());
192
}
193
194
// Get specific table
195
TableDefinition usersTable = database.getTable(schema, "users");
196
if (usersTable != null) {
197
System.out.println("Found users table with " + usersTable.getColumns().size() + " columns");
198
}
199
200
// Case-insensitive lookup
201
TableDefinition table = database.getTable(schema, "Users", true);
202
203
// Using jOOQ Name
204
Name tableName = DSL.name("customer_orders");
205
TableDefinition ordersTable = database.getTable(schema, tableName);
206
```
207
208
### Object Existence Checking
209
210
Utility methods for checking existence of database objects before access.
211
212
```java { .api }
213
/**
214
* Checks if a table field exists in the database
215
* @param field - Table field to check
216
* @returns true if the field exists
217
*/
218
boolean exists(TableField<?, ?> field);
219
220
/**
221
* Checks if all specified table fields exist
222
* @param fields - Array of table fields to check
223
* @returns true if all fields exist
224
*/
225
boolean existAll(TableField<?, ?>... fields);
226
227
/**
228
* Checks if a table exists in the database
229
* @param table - Table to check
230
* @returns true if the table exists
231
*/
232
boolean exists(Table<?> table);
233
234
/**
235
* Checks if all specified tables exist
236
* @param tables - Array of tables to check
237
* @returns true if all tables exist
238
*/
239
boolean existAll(Table<?>... tables);
240
```
241
242
### Schema Navigation and Hierarchy
243
244
Methods for navigating the schema hierarchy and understanding object relationships.
245
246
```java { .api }
247
/**
248
* Gets the definition path for hierarchical navigation
249
* @returns List of definitions representing the hierarchy path
250
*/
251
List<Definition> getDefinitionPath();
252
253
/**
254
* Gets qualified name parts for the object
255
* @returns jOOQ Name representing qualified name
256
*/
257
Name getQualifiedNamePart();
258
259
/**
260
* Gets all partially qualified names for caching and lookup
261
* @returns List of partially qualified name strings
262
*/
263
List<String> getPartiallyQualifiedNames();
264
```
265
266
## Types
267
268
```java { .api }
269
interface CatalogDefinition extends Definition {
270
String getName();
271
String getComment();
272
Database getDatabase();
273
}
274
275
interface SchemaDefinition extends Definition {
276
String getName();
277
String getComment();
278
CatalogDefinition getCatalog();
279
Database getDatabase();
280
}
281
282
interface Definition {
283
String getName();
284
String getInputName();
285
String getOutputName();
286
String getComment();
287
String getQualifiedName();
288
String getQualifiedInputName();
289
String getQualifiedOutputName();
290
List<Definition> getDefinitionPath();
291
Database getDatabase();
292
SchemaDefinition getSchema();
293
CatalogDefinition getCatalog();
294
}
295
```
296
297
**Usage Examples:**
298
299
```java
300
import org.jooq.meta.Database;
301
import org.jooq.meta.CatalogDefinition;
302
import org.jooq.meta.SchemaDefinition;
303
import org.jooq.meta.TableDefinition;
304
305
// Complete schema discovery
306
List<CatalogDefinition> catalogs = database.getCatalogs();
307
for (CatalogDefinition catalog : catalogs) {
308
System.out.println("Catalog: " + catalog.getName());
309
310
List<SchemaDefinition> schemas = database.getSchemata(catalog);
311
for (SchemaDefinition schema : schemas) {
312
System.out.println(" Schema: " + schema.getName());
313
314
List<TableDefinition> tables = database.getTables(schema);
315
for (TableDefinition table : tables) {
316
System.out.println(" Table: " + table.getName());
317
System.out.println(" Qualified: " + table.getQualifiedName());
318
System.out.println(" Comment: " + table.getComment());
319
}
320
}
321
}
322
323
// Schema hierarchy navigation
324
TableDefinition table = database.getTable(schema, "orders");
325
List<Definition> path = table.getDefinitionPath();
326
// Path: [catalog] -> [schema] -> [table]
327
```