or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-objects.mdconfiguration.mdconstraints-relationships.mddatabase-implementations.mddatabase-management.mdindex.mdschema-discovery.mdtable-analysis.md

table-analysis.mddocs/

0

# Table and Column Analysis

1

2

Detailed table structure analysis including columns, data types, nullability, defaults, identity columns, and special properties for comprehensive database schema understanding.

3

4

## Capabilities

5

6

### Table Structure Analysis

7

8

Core table analysis providing detailed information about table properties and characteristics.

9

10

```java { .api }

11

/**

12

* Gets all visible columns in the table

13

* @returns List of column definitions (excludes hidden columns)

14

*/

15

List<ColumnDefinition> getColumns();

16

17

/**

18

* Gets all columns including hidden system columns

19

* @returns List of all column definitions including hidden ones

20

*/

21

List<ColumnDefinition> getColumnsIncludingHidden();

22

23

/**

24

* Gets a specific column by name

25

* @param name - Column name to lookup

26

* @returns Column definition or null if not found

27

*/

28

ColumnDefinition getColumn(String name);

29

30

/**

31

* Gets a specific column with case sensitivity control

32

* @param name - Column name to lookup

33

* @param ignoreCase - Whether to ignore case in name matching

34

* @returns Column definition or null if not found

35

*/

36

ColumnDefinition getColumn(String name, boolean ignoreCase);

37

38

/**

39

* Gets a specific column by jOOQ Name

40

* @param name - jOOQ Name object for the column

41

* @returns Column definition or null if not found

42

*/

43

ColumnDefinition getColumn(Name name);

44

45

/**

46

* Gets a specific column by jOOQ Name with case sensitivity control

47

* @param name - jOOQ Name object for the column

48

* @param ignoreCase - Whether to ignore case in name matching

49

* @returns Column definition or null if not found

50

*/

51

ColumnDefinition getColumn(Name name, boolean ignoreCase);

52

```

53

54

**Usage Examples:**

55

56

```java

57

import org.jooq.meta.TableDefinition;

58

import org.jooq.meta.ColumnDefinition;

59

import org.jooq.Name;

60

import org.jooq.impl.DSL;

61

62

// Get all columns

63

List<ColumnDefinition> columns = table.getColumns();

64

for (ColumnDefinition column : columns) {

65

System.out.println("Column: " + column.getName());

66

System.out.println(" Type: " + column.getType().getType());

67

System.out.println(" Nullable: " + column.getType().isNullable());

68

System.out.println(" Position: " + column.getPosition());

69

}

70

71

// Get specific column

72

ColumnDefinition idColumn = table.getColumn("id");

73

if (idColumn != null && idColumn.isIdentity()) {

74

System.out.println("Found identity column: " + idColumn.getName());

75

}

76

77

// Case-insensitive lookup

78

ColumnDefinition column = table.getColumn("Email", true);

79

80

// Using jOOQ Name

81

Name columnName = DSL.name("created_at");

82

ColumnDefinition createdAt = table.getColumn(columnName);

83

84

// Include hidden columns

85

List<ColumnDefinition> allColumns = table.getColumnsIncludingHidden();

86

System.out.println("Total columns (including hidden): " + allColumns.size());

87

```

88

89

### Table Type Identification

90

91

Methods to identify different types of tables and table-like objects.

92

93

```java { .api }

94

/**

95

* Checks if this table is a view

96

* @returns true if the table is a view

97

*/

98

boolean isView();

99

100

/**

101

* Checks if this table is a materialized view

102

* @returns true if the table is a materialized view

103

*/

104

boolean isMaterializedView();

105

106

/**

107

* Checks if this table is a table-valued function

108

* @returns true if the table represents a table-valued function

109

*/

110

boolean isTableValuedFunction();

111

112

/**

113

* Checks if this table is temporary

114

* @returns true if the table is temporary

115

*/

116

boolean isTemporary();

117

118

/**

119

* Checks if this table is synthetic (artificially generated)

120

* @returns true if the table is synthetic

121

*/

122

boolean isSynthetic();

123

```

124

125

**Usage Examples:**

126

127

```java

128

import org.jooq.meta.TableDefinition;

129

130

// Identify table types

131

for (TableDefinition table : tables) {

132

System.out.print("Table: " + table.getName() + " - ");

133

134

if (table.isView()) {

135

System.out.println("VIEW");

136

} else if (table.isMaterializedView()) {

137

System.out.println("MATERIALIZED VIEW");

138

} else if (table.isTableValuedFunction()) {

139

System.out.println("TABLE-VALUED FUNCTION");

140

} else if (table.isTemporary()) {

141

System.out.println("TEMPORARY TABLE");

142

} else {

143

System.out.println("TABLE");

144

}

145

}

146

```

147

148

### Column Data Type Analysis

149

150

Comprehensive column data type analysis including type information, precision, scale, and special properties.

151

152

```java { .api }

153

/**

154

* Gets the column's data type definition

155

* @returns DataTypeDefinition with complete type information

156

*/

157

DataTypeDefinition getType();

158

159

/**

160

* Gets the column position within the table

161

* @returns Zero-based position of the column

162

*/

163

int getPosition();

164

165

/**

166

* Checks if the column is an identity/auto-increment column

167

* @returns true if the column is an identity column

168

*/

169

boolean isIdentity();

170

171

/**

172

* Checks if the column can contain null values

173

* @returns true if the column is nullable

174

*/

175

boolean isNullable();

176

177

/**

178

* Checks if the column is hidden (system column)

179

* @returns true if the column is hidden

180

*/

181

boolean isHidden();

182

183

/**

184

* Checks if the column is readonly

185

* @returns true if the column is readonly

186

*/

187

boolean isReadonly();

188

189

/**

190

* Gets the column's default value expression

191

* @returns Default value string or null if no default

192

*/

193

String getDefaultValue();

194

```

195

196

**Usage Examples:**

197

198

```java

199

import org.jooq.meta.ColumnDefinition;

200

import org.jooq.meta.DataTypeDefinition;

201

202

// Analyze column properties

203

ColumnDefinition column = table.getColumn("email");

204

if (column != null) {

205

DataTypeDefinition type = column.getType();

206

207

System.out.println("Column: " + column.getName());

208

System.out.println(" Data Type: " + type.getType());

209

System.out.println(" Java Type: " + type.getJavaType());

210

System.out.println(" Length: " + type.getLength());

211

System.out.println(" Precision: " + type.getPrecision());

212

System.out.println(" Scale: " + type.getScale());

213

System.out.println(" Nullable: " + type.isNullable());

214

System.out.println(" Default: " + column.getDefaultValue());

215

System.out.println(" Position: " + column.getPosition());

216

System.out.println(" Identity: " + column.isIdentity());

217

System.out.println(" Hidden: " + column.isHidden());

218

System.out.println(" Readonly: " + column.isReadonly());

219

}

220

221

// Find identity columns

222

List<ColumnDefinition> identityColumns = table.getColumns().stream()

223

.filter(ColumnDefinition::isIdentity)

224

.collect(Collectors.toList());

225

226

// Find nullable columns

227

List<ColumnDefinition> nullableColumns = table.getColumns().stream()

228

.filter(col -> col.getType().isNullable())

229

.collect(Collectors.toList());

230

```

231

232

### Data Type Details

233

234

Detailed analysis of database data types and their properties.

235

236

```java { .api }

237

/**

238

* Gets database type name

239

* @returns Native database type name

240

*/

241

String getType();

242

243

/**

244

* Gets corresponding Java type name

245

* @returns Java type name for code generation

246

*/

247

String getJavaType();

248

249

/**

250

* Gets type length for character/binary types

251

* @returns Type length or 0 if not applicable

252

*/

253

int getLength();

254

255

/**

256

* Gets numeric precision

257

* @returns Numeric precision or 0 if not applicable

258

*/

259

int getPrecision();

260

261

/**

262

* Gets numeric scale

263

* @returns Numeric scale or 0 if not applicable

264

*/

265

int getScale();

266

267

/**

268

* Checks if column has default value

269

* @returns true if column has a default value

270

*/

271

boolean isDefaulted();

272

273

/**

274

* Checks if column is identity/auto-increment

275

* @returns true if column is identity

276

*/

277

boolean isIdentity();

278

279

/**

280

* Checks if column is readonly

281

* @returns true if column is readonly

282

*/

283

boolean isReadonly();

284

```

285

286

### Container and Parent Relationships

287

288

Methods for navigating from columns back to their containing tables and schemas.

289

290

```java { .api }

291

/**

292

* Gets the table containing this column

293

* @returns TableDefinition that contains this column

294

*/

295

TableDefinition getContainer();

296

297

/**

298

* Gets the schema containing this column's table

299

* @returns SchemaDefinition containing the table

300

*/

301

SchemaDefinition getSchema();

302

303

/**

304

* Gets the catalog containing this column's schema

305

* @returns CatalogDefinition containing the schema

306

*/

307

CatalogDefinition getCatalog();

308

309

/**

310

* Gets the database containing this column

311

* @returns Database containing this column

312

*/

313

Database getDatabase();

314

```

315

316

## Types

317

318

```java { .api }

319

interface TableDefinition extends Definition {

320

List<ColumnDefinition> getColumns();

321

List<ColumnDefinition> getColumnsIncludingHidden();

322

ColumnDefinition getColumn(String name);

323

ColumnDefinition getColumn(String name, boolean ignoreCase);

324

ColumnDefinition getColumn(Name name);

325

ColumnDefinition getColumn(Name name, boolean ignoreCase);

326

boolean isView();

327

boolean isMaterializedView();

328

boolean isTableValuedFunction();

329

boolean isTemporary();

330

}

331

332

interface ColumnDefinition extends TypedElementDefinition<TableDefinition>, PositionedDefinition {

333

TableDefinition getContainer();

334

DataTypeDefinition getType();

335

boolean isIdentity();

336

boolean isNullable();

337

boolean isHidden();

338

boolean isReadonly();

339

String getDefaultValue();

340

int getPosition();

341

}

342

343

interface DataTypeDefinition {

344

String getType();

345

String getJavaType();

346

int getLength();

347

int getPrecision();

348

int getScale();

349

boolean isNullable();

350

boolean isDefaulted();

351

boolean isIdentity();

352

boolean isReadonly();

353

}

354

355

interface TypedElementDefinition<T extends Definition> extends Definition {

356

T getContainer();

357

DataTypeDefinition getType();

358

}

359

360

interface PositionedDefinition extends Definition {

361

int getPosition();

362

}

363

```

364

365

**Usage Examples:**

366

367

```java

368

import org.jooq.meta.TableDefinition;

369

import org.jooq.meta.ColumnDefinition;

370

import org.jooq.meta.DataTypeDefinition;

371

372

// Complete table analysis

373

TableDefinition table = database.getTable(schema, "products");

374

375

System.out.println("Table: " + table.getName());

376

System.out.println("Type: " + (table.isView() ? "VIEW" : "TABLE"));

377

System.out.println("Columns: " + table.getColumns().size());

378

379

// Analyze each column

380

for (ColumnDefinition column : table.getColumns()) {

381

DataTypeDefinition type = column.getType();

382

383

System.out.println("\nColumn: " + column.getName());

384

System.out.println(" Position: " + column.getPosition());

385

System.out.println(" Type: " + type.getType());

386

System.out.println(" Java Type: " + type.getJavaType());

387

388

if (type.getLength() > 0) {

389

System.out.println(" Length: " + type.getLength());

390

}

391

if (type.getPrecision() > 0) {

392

System.out.println(" Precision: " + type.getPrecision());

393

System.out.println(" Scale: " + type.getScale());

394

}

395

396

System.out.println(" Nullable: " + type.isNullable());

397

System.out.println(" Identity: " + column.isIdentity());

398

399

if (column.getDefaultValue() != null) {

400

System.out.println(" Default: " + column.getDefaultValue());

401

}

402

403

// Navigate back to container

404

System.out.println(" Table: " + column.getContainer().getName());

405

System.out.println(" Schema: " + column.getSchema().getName());

406

}

407

```