or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

datasource-configuration.mdindex.mdmonitoring-statistics.mdsecurity-filtering.mdsql-processing.md

sql-processing.mddocs/

0

# SQL Processing

1

2

Comprehensive SQL parsing, formatting, and manipulation capabilities supporting 50+ database dialects with full AST (Abstract Syntax Tree) manipulation and transformation features.

3

4

## Core SQL Processing

5

6

### SQLUtils - Primary SQL Processing API

7

8

#### SQL Parsing Methods

9

10

```java { .api }

11

// Statement parsing

12

static List<SQLStatement> parseStatements(String sql, String dbType, SQLParserFeature... features);

13

static List<SQLStatement> parseStatements(String sql, DbType dbType, SQLParserFeature... features);

14

static List<SQLStatement> parseStatements(String sql, DbType dbType, boolean keepComments);

15

static List<SQLStatement> parseStatements(String sql, String dbType);

16

static List<SQLStatement> parseStatements(String sql, DbType dbType);

17

static SQLStatement parseSingleStatement(String sql, DbType dbType, boolean keepComments);

18

static SQLStatement parseSingleStatement(String sql, String dbType, SQLParserFeature... features);

19

static SQLStatement parseSingleStatement(String sql, DbType dbType, SQLParserFeature... features);

20

static SQLStatement parseSingleMysqlStatement(String sql);

21

22

// Expression and component parsing

23

static SQLExpr toSQLExpr(String sql, DbType dbType);

24

static SQLExpr toSQLExpr(String sql, DbType dbType, SQLParserFeature... features);

25

static SQLExpr toSQLExpr(String sql);

26

static SQLExpr toMySqlExpr(String sql);

27

static SQLSelectOrderByItem toOrderByItem(String sql, DbType dbType);

28

static SQLUpdateSetItem toUpdateSetItem(String sql, DbType dbType);

29

static SQLSelectItem toSelectItem(String sql, DbType dbType);

30

static List<SQLStatement> toStatementList(String sql, DbType dbType);

31

```

32

33

#### SQL String Conversion Methods

34

35

```java { .api }

36

// Generic SQL string conversion

37

static String toSQLString(SQLObject sqlObject, String dbType);

38

static String toSQLString(SQLObject sqlObject, DbType dbType);

39

static String toSQLString(SQLObject sqlObject, DbType dbType, FormatOption option);

40

static String toSQLString(SQLObject sqlObject, DbType dbType, FormatOption option, VisitorFeature... features);

41

static String toSQLString(SQLObject obj);

42

static String toSQLString(List<SQLStatement> statementList, DbType dbType);

43

static String toSQLString(List<SQLStatement> statementList, DbType dbType, FormatOption option);

44

static String toSQLString(List<SQLStatement> statementList, DbType dbType, List<Object> parameters);

45

static String toSQLString(List<SQLStatement> statementList, DbType dbType, List<Object> parameters, FormatOption option);

46

static String toSQLString(List<SQLStatement> statementList, DbType dbType, SQLASTOutputVisitor visitor);

47

48

// Database-specific string conversion

49

static String toOdpsString(SQLObject sqlObject);

50

static String toOdpsString(SQLObject sqlObject, FormatOption option);

51

static String toHiveString(SQLObject sqlObject);

52

static String toAntsparkString(SQLObject sqlObject);

53

static String toAntsparkString(SQLObject sqlObject, FormatOption option);

54

static String toMySqlString(SQLObject sqlObject);

55

static String toMySqlString(SQLObject sqlObject, VisitorFeature... features);

56

static String toMySqlString(SQLObject sqlObject, FormatOption option);

57

static String toMySqlStringIfNotNull(SQLObject sqlObject, String defaultStr);

58

static String toNormalizeMysqlString(SQLObject sqlObject);

59

static String toOracleString(SQLObject sqlObject);

60

static String toOracleString(SQLObject sqlObject, FormatOption option);

61

static String toPGString(SQLObject sqlObject);

62

static String toPGString(SQLObject sqlObject, FormatOption option);

63

static String toDB2String(SQLObject sqlObject);

64

static String toDB2String(SQLObject sqlObject, FormatOption option);

65

static String toSQLServerString(SQLObject sqlObject);

66

static String toSQLServerString(SQLObject sqlObject, FormatOption option);

67

```

68

69

#### SQL Formatting Methods

70

71

```java { .api }

72

// Generic formatting

73

static String format(String sql, String dbType);

74

static String format(String sql, DbType dbType);

75

static String format(String sql, DbType dbType, FormatOption option);

76

static String format(String sql, DbType dbType, List<Object> parameters);

77

static String format(String sql, DbType dbType, List<Object> parameters, FormatOption option);

78

static String format(String sql, DbType dbType, List<Object> parameters, FormatOption option, SQLParserFeature[] features);

79

80

// Database-specific formatting

81

static String formatMySql(String sql);

82

static String formatMySql(String sql, FormatOption option);

83

static String formatOracle(String sql);

84

static String formatOracle(String sql, FormatOption option);

85

static String formatOdps(String sql);

86

static String formatOdps(String sql, FormatOption option);

87

static String formatPresto(String sql);

88

static String formatPresto(String sql, FormatOption option);

89

static String formatHive(String sql);

90

static String formatHive(String sql, FormatOption option);

91

static String formatSQLServer(String sql);

92

static String formatPGSql(String sql, FormatOption option);

93

```

94

95

#### SQL Manipulation and Transformation

96

97

```java { .api }

98

// Condition manipulation

99

static String addCondition(String sql, String condition, DbType dbType);

100

static String addCondition(String sql, String condition, SQLBinaryOperator op, boolean left, DbType dbType);

101

static void addCondition(SQLStatement stmt, SQLBinaryOperator op, SQLExpr condition, boolean left);

102

static SQLExpr buildCondition(SQLBinaryOperator op, SQLExpr condition, boolean left, SQLExpr where);

103

104

// Select item manipulation

105

static String addSelectItem(String selectSql, String expr, String alias, DbType dbType);

106

static String addSelectItem(String selectSql, String expr, String alias, boolean first, DbType dbType);

107

static void addSelectItem(SQLStatement stmt, SQLExpr expr, String alias, boolean first);

108

static void addSelectItem(SQLSelectQueryBlock queryBlock, SQLExpr expr, String alias, boolean first);

109

110

// SQL transformation

111

static String translateOracleToMySql(String sql);

112

static String refactor(String sql, DbType dbType, Map<String, String> tableMapping);

113

static String sort(String sql, DbType dbType);

114

static Object[] clearLimit(String query, DbType dbType);

115

static SQLLimit getLimit(SQLStatement statement, DbType dbType);

116

static SQLLimit getLimit(String query, DbType dbType);

117

static List<SQLInsertStatement> splitInsertValues(DbType dbType, String insertSql, int size);

118

```

119

120

#### Analysis and Utility Methods

121

122

```java { .api }

123

// SQL analysis

124

static long hash(String sql, DbType dbType);

125

static List<SQLExpr> split(SQLBinaryOpExpr x);

126

static SQLExpr not(SQLExpr expr);

127

128

// Name and value utilities

129

static String normalize(String name);

130

static String normalize(String name, boolean isTrimmed);

131

static String normalize(String name, DbType dbType);

132

static String forcedNormalize(String name, DbType dbType);

133

static boolean nameEquals(SQLName a, SQLName b);

134

static boolean nameEquals(String a, String b);

135

static boolean isValue(SQLExpr expr);

136

static boolean isQuoteChar(char c);

137

static String removeQuote(String str);

138

139

// Security utilities

140

static String desensitizeTable(String tableName);

141

142

// Date/Time handling

143

static String buildToDate(String columnName, String tableAlias, String pattern, DbType dbType);

144

static String convertTimeZone(String sql, TimeZone from, TimeZone to);

145

static SQLStatement convertTimeZone(SQLStatement stmt, TimeZone from, TimeZone to);

146

```

147

148

#### Replacement and Manipulation Utilities

149

150

```java { .api }

151

// AST node replacement

152

static boolean replaceInParent(SQLDataType expr, SQLDataType target);

153

static boolean replaceInParent(SQLExpr expr, SQLExpr target);

154

static boolean replaceInParent(SQLSelect cmp, SQLSelect dest);

155

static boolean replaceInParent(SQLTableSource cmp, SQLTableSource dest);

156

static boolean replaceInParent(SQLSelectQuery cmp, SQLSelectQuery dest);

157

static boolean replaceInParent(SQLStatement cmp, SQLStatement dest);

158

```

159

160

#### Visitor Creation Methods

161

162

```java { .api }

163

// Visitor pattern support

164

static SQLASTOutputVisitor createOutputVisitor(StringBuilder out, DbType dbType);

165

static SQLASTOutputVisitor createFormatOutputVisitor(StringBuilder out, List<SQLStatement> statementList, DbType dbType);

166

static SchemaStatVisitor createSchemaStatVisitor(DbType dbType);

167

static SchemaStatVisitor createSchemaStatVisitor(List<SQLStatement> statementList, DbType dbType); // @Deprecated

168

static SchemaStatVisitor createSchemaStatVisitor(SchemaRepository repository);

169

static SchemaStatVisitor createSchemaStatVisitor(SchemaRepository repository, DbType dbType);

170

```

171

172

#### Visitor Pattern Analysis Methods

173

174

```java { .api }

175

// SQL component analysis with visitor pattern

176

static void acceptBooleanOr(String sql, DbType dbType, Consumer<SQLBinaryOpExprGroup> consumer);

177

static void acceptBinaryOpExprGroup(String sql, DbType dbType, Consumer<SQLBinaryOpExprGroup> consumer, Predicate<SQLBinaryOpExprGroup> filter);

178

static void acceptBinaryOpExpr(String sql, DbType dbType, Consumer<SQLBinaryOpExpr> consumer, Predicate<SQLBinaryOpExpr> filter);

179

static void acceptTableSource(String sql, DbType dbType, Consumer<SQLTableSource> consumer, Predicate<SQLTableSource> filter);

180

static void acceptSelectQueryBlock(String sql, DbType dbType, Consumer<SQLSelectQueryBlock> consumer, Predicate<SQLSelectQueryBlock> filter);

181

static void acceptAggregateFunction(String sql, DbType dbType, Consumer<SQLAggregateExpr> consumer, Predicate<SQLAggregateExpr> filter);

182

static void acceptFunction(String sql, DbType dbType, Consumer<SQLMethodInvokeExpr> consumer, Predicate<SQLMethodInvokeExpr> filter);

183

static void acceptInsertInto(String sql, DbType dbType, Consumer<SQLInsertInto> consumer, Predicate<SQLInsertInto> filter);

184

```

185

186

### Database Type Support

187

188

```java { .api }

189

// Database type enumeration supporting 50+ databases

190

enum DbType {

191

// Major relational databases

192

mysql, mariadb, tidb, polardbx, goldendb,

193

oracle, oceanbase_oracle, ali_oracle,

194

postgresql, greenplum, edb, gaussdb, hologres, redshift,

195

sqlserver, jtds,

196

197

// Cloud and big data platforms

198

odps, // MaxCompute

199

hive, spark, databricks,

200

clickhouse, presto, trino,

201

snowflake, bigquery,

202

203

// Other databases

204

db2, h2, sqlite, derby, hsqldb,

205

informix, teradata, sybase,

206

starrocks, doris, dm, kingbase,

207

208

// And 20+ more specialized databases

209

}

210

```

211

212

## SQL Parsing Examples

213

214

### Basic SQL Parsing

215

216

```java

217

import com.alibaba.druid.sql.SQLUtils;

218

import com.alibaba.druid.sql.ast.SQLStatement;

219

import com.alibaba.druid.DbType;

220

221

// Parse single SQL statement

222

String sql = "SELECT id, name FROM users WHERE age > 18";

223

SQLStatement statement = SQLUtils.parseSingleStatement(sql, DbType.mysql);

224

225

// Parse multiple statements

226

String multipleSql = "INSERT INTO users (name) VALUES ('John'); SELECT * FROM users;";

227

List<SQLStatement> statements = SQLUtils.parseStatements(multipleSql, DbType.mysql);

228

229

// Parse with features

230

SQLStatement stmt = SQLUtils.parseSingleStatement(sql, DbType.mysql,

231

SQLParserFeature.KeepComments,

232

SQLParserFeature.KeepNameQuotes);

233

```

234

235

### SQL Expression Parsing

236

237

```java

238

// Parse expressions

239

SQLExpr expr = SQLUtils.toSQLExpr("age > 18 AND status = 'active'", DbType.mysql);

240

SQLSelectItem selectItem = SQLUtils.toSelectItem("COUNT(*) as total", DbType.mysql);

241

SQLOrderByItem orderBy = SQLUtils.toOrderByItem("name DESC", DbType.mysql);

242

```

243

244

## SQL Formatting and Output

245

246

### SQL Formatting Options

247

248

```java { .api }

249

// Format option configuration class within SQLUtils

250

static class FormatOption {

251

// Constructors

252

public FormatOption();

253

public FormatOption(VisitorFeature... features);

254

public FormatOption(boolean ucase);

255

public FormatOption(boolean ucase, boolean prettyFormat);

256

public FormatOption(boolean ucase, boolean prettyFormat, boolean parameterized);

257

258

// Configuration methods

259

public boolean isUppCase();

260

public void setUppCase(boolean uppCase);

261

public boolean isPrettyFormat();

262

public void setPrettyFormat(boolean prettyFormat);

263

public boolean isParameterized();

264

public void setParameterized(boolean parameterized);

265

public boolean isDesensitize();

266

public void setDesensitize(boolean desensitize);

267

268

// Feature configuration

269

public void config(VisitorFeature feature, boolean state);

270

public void configTo(SQLASTOutputVisitor visitor);

271

public boolean isEnabled(VisitorFeature feature);

272

}

273

274

// Constants for default format options

275

static final FormatOption DEFAULT_FORMAT_OPTION = new FormatOption(true, true);

276

static final FormatOption DEFAULT_LCASE_FORMAT_OPTION = new FormatOption(false, true);

277

```

278

279

### Formatting Examples

280

281

```java

282

import com.alibaba.druid.sql.SQLUtils;

283

import com.alibaba.druid.sql.SQLUtils.FormatOption;

284

285

String sql = "select*from users where id=1";

286

287

// Basic formatting

288

String formatted = SQLUtils.format(sql, DbType.mysql);

289

// Result: SELECT *\nFROM users\nWHERE id = 1

290

291

// Pretty formatting with options

292

FormatOption option = new FormatOption(true, true); // uppercase, pretty

293

String prettyFormatted = SQLUtils.format(sql, DbType.mysql, option);

294

295

// Database-specific formatting

296

String mysqlFormatted = SQLUtils.formatMySql(sql, option);

297

String oracleFormatted = SQLUtils.formatOracle(sql, option);

298

String pgFormatted = SQLUtils.formatPostgreSQL(sql, option);

299

```

300

301

## SQL Manipulation and Transformation

302

303

### Adding Conditions and Clauses

304

305

```java { .api }

306

// SQL manipulation methods

307

static String addCondition(String sql, String condition, SQLBinaryOperator op, boolean left, DbType dbType);

308

static String addSelectItem(String sql, String expr, String alias, boolean first, DbType dbType);

309

static String refactor(String sql, DbType dbType, Map<String, String> tableMapping);

310

static String normalize(String name, DbType dbType);

311

static List<SQLBinaryOpExpr> split(SQLBinaryOpExpr x);

312

```

313

314

### SQL Manipulation Examples

315

316

```java

317

// Add WHERE condition

318

String originalSql = "SELECT * FROM users";

319

String withCondition = SQLUtils.addCondition(originalSql, "age > 18",

320

SQLBinaryOperator.BooleanAnd, false, DbType.mysql);

321

// Result: SELECT * FROM users WHERE age > 18

322

323

// Add SELECT item

324

String withColumn = SQLUtils.addSelectItem(originalSql, "created_date", "creation",

325

false, DbType.mysql);

326

// Result: SELECT *, created_date AS creation FROM users

327

328

// Refactor table names

329

Map<String, String> tableMapping = new HashMap<>();

330

tableMapping.put("users", "customers");

331

String refactored = SQLUtils.refactor("SELECT * FROM users", DbType.mysql, tableMapping);

332

// Result: SELECT * FROM customers

333

```

334

335

## SQL Parser Utilities

336

337

### SQLParserUtils - Parser Factory Methods

338

339

```java { .api }

340

// Parser creation

341

static SQLStatementParser createSQLStatementParser(String sql, DbType dbType, SQLParserFeature... features);

342

static SQLExprParser createExprParser(String sql, DbType dbType, SQLParserFeature... features);

343

static Lexer createLexer(String sql, DbType dbType, SQLParserFeature... features);

344

345

// SQL analysis

346

static SQLType getSQLType(String sql, DbType dbType);

347

static boolean containsAny(String sql, DbType dbType, Token... tokens);

348

static Object getSimpleSelectValue(String sql, DbType dbType);

349

static List<String> split(String sql, DbType dbType);

350

static String removeComment(String sql, DbType dbType);

351

static Collection<String> getTables(String sql, DbType dbType);

352

```

353

354

### SQL Analysis Examples

355

356

```java

357

import com.alibaba.druid.sql.parser.SQLParserUtils;

358

import com.alibaba.druid.sql.parser.Token;

359

360

// Determine SQL statement type

361

SQLType type = SQLParserUtils.getSQLType("SELECT * FROM users", DbType.mysql);

362

// Returns: SQLType.SELECT

363

364

// Extract table names

365

Collection<String> tables = SQLParserUtils.getTables(

366

"SELECT u.id, p.name FROM users u JOIN profiles p ON u.id = p.user_id",

367

DbType.mysql);

368

// Returns: ["users", "profiles"]

369

370

// Remove comments

371

String cleaned = SQLParserUtils.removeComment(

372

"SELECT * FROM users -- get all users", DbType.mysql);

373

// Returns: "SELECT * FROM users"

374

375

// Split multi-statement SQL

376

List<String> statements = SQLParserUtils.split(

377

"INSERT INTO users (name) VALUES ('John'); SELECT * FROM users;",

378

DbType.mysql);

379

```

380

381

## Pagination Support

382

383

### PagerUtils - Pagination Utilities

384

385

```java { .api }

386

// Pagination methods

387

class PagerUtils {

388

static String limit(String sql, DbType dbType, int offset, int count, boolean check);

389

static String count(String sql, DbType dbType);

390

static PagerUtils.Limit getLimit(String sql, DbType dbType);

391

static boolean hasUnorderedLimit(String sql, DbType dbType);

392

}

393

```

394

395

### Pagination Examples

396

397

```java

398

import com.alibaba.druid.sql.PagerUtils;

399

400

String sql = "SELECT * FROM users ORDER BY name";

401

402

// Add pagination

403

String pagedSql = PagerUtils.limit(sql, DbType.mysql, 20, 10, true);

404

// Result: SELECT * FROM users ORDER BY name LIMIT 20, 10

405

406

// Convert to count query

407

String countSql = PagerUtils.count(sql, DbType.mysql);

408

// Result: SELECT COUNT(*) FROM users

409

410

// Extract existing limit

411

PagerUtils.Limit limit = PagerUtils.getLimit(

412

"SELECT * FROM users LIMIT 10, 20", DbType.mysql);

413

// Returns limit object with offset=10, rowCount=20

414

```

415

416

## AST (Abstract Syntax Tree) API

417

418

### Core AST Interfaces

419

420

```java { .api }

421

// Base AST interfaces

422

interface SQLObject {

423

void accept(SQLASTVisitor visitor);

424

SQLObject clone();

425

String toString();

426

}

427

428

interface SQLStatement extends SQLObject {

429

DbType getDbType();

430

void setDbType(DbType dbType);

431

List<SQLCommentHint> getHeadHintsDirect();

432

}

433

434

interface SQLExpr extends SQLObject {

435

SQLExpr clone();

436

boolean equals(Object o);

437

int hashCode();

438

}

439

```

440

441

### Key AST Statement Classes

442

443

```java { .api }

444

// Statement implementations

445

class SQLSelectStatement implements SQLStatement {

446

public SQLSelectQuery getSelect();

447

public void setSelect(SQLSelectQuery select);

448

}

449

450

class SQLInsertStatement implements SQLStatement {

451

public SQLExprTableSource getTableSource();

452

public List<SQLExpr> getColumns();

453

public SQLInsertStatement.ValuesClause getValues();

454

}

455

456

class SQLUpdateStatement implements SQLStatement {

457

public SQLTableSource getTableSource();

458

public List<SQLUpdateSetItem> getItems();

459

public SQLExpr getWhere();

460

}

461

```

462

463

## Visitor Pattern for AST Traversal

464

465

### Visitor Interfaces

466

467

```java { .api }

468

// Main visitor interface

469

interface SQLASTVisitor {

470

// Visit methods for all AST node types

471

boolean visit(SQLSelectStatement x);

472

void endVisit(SQLSelectStatement x);

473

boolean visit(SQLInsertStatement x);

474

void endVisit(SQLInsertStatement x);

475

// ... hundreds more visit methods

476

}

477

478

// Output visitor for generating SQL

479

class SQLASTOutputVisitor implements SQLASTVisitor {

480

public SQLASTOutputVisitor(StringBuilder out);

481

public SQLASTOutputVisitor(StringBuilder out, DbType dbType);

482

public String getSql();

483

}

484

```

485

486

### Visitor Usage Examples

487

488

```java

489

import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;

490

import com.alibaba.druid.sql.visitor.SchemaStatVisitor;

491

492

// Generate SQL from AST

493

StringBuilder out = new StringBuilder();

494

SQLASTOutputVisitor visitor = new SQLASTOutputVisitor(out, DbType.mysql);

495

statement.accept(visitor);

496

String sql = visitor.getSql();

497

498

// Analyze schema information

499

SchemaStatVisitor schemaVisitor = new SchemaStatVisitor(DbType.mysql);

500

statement.accept(schemaVisitor);

501

Set<TableStat.Name> tables = schemaVisitor.getTables().keySet();

502

Set<TableStat.Column> columns = schemaVisitor.getColumns();

503

```

504

505

## Parser Features and Configuration

506

507

### SQLParserFeature Options

508

509

```java { .api }

510

// Parser feature flags

511

enum SQLParserFeature {

512

KeepComments, // Preserve SQL comments

513

KeepNameQuotes, // Preserve identifier quotes

514

EnableSQLBinaryOpExprGroup, // Group binary operations

515

OptimizedForParameterized, // Optimize for parameterized queries

516

StrictForWall, // Enable security wall features

517

IgnoreNameQuotes, // Ignore identifier quotes

518

InsertReader, // Optimized INSERT parsing

519

// ... more features

520

}

521

```

522

523

## Exception Handling

524

525

### SQL Processing Exceptions

526

527

```java { .api }

528

// Exception classes

529

class ParserException extends RuntimeException {

530

public ParserException(String message);

531

public ParserException(String message, Throwable cause);

532

public int getLine();

533

public int getColumn();

534

}

535

536

class SQLParseException extends ParserException {

537

public SQLParseException(String message);

538

public SQLParseException(String message, Throwable cause);

539

}

540

541

class FastsqlException extends RuntimeException {

542

public FastsqlException(String message);

543

public FastsqlException(String message, Throwable cause);

544

}

545

```

546

547

## Advanced SQL Processing Examples

548

549

### Complex SQL Transformation

550

551

```java

552

import com.alibaba.druid.sql.ast.SQLStatement;

553

import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;

554

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery;

555

import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;

556

557

// Parse complex query

558

String complexSql = """

559

SELECT u.id, u.name, p.title, COUNT(o.id) as order_count

560

FROM users u

561

LEFT JOIN profiles p ON u.id = p.user_id

562

LEFT JOIN orders o ON u.id = o.user_id

563

WHERE u.active = 1

564

GROUP BY u.id, u.name, p.title

565

HAVING COUNT(o.id) > 5

566

ORDER BY order_count DESC

567

LIMIT 100

568

""";

569

570

SQLStatement stmt = SQLUtils.parseSingleStatement(complexSql, DbType.mysql);

571

572

// Transform and regenerate

573

StringBuilder output = new StringBuilder();

574

SQLASTOutputVisitor visitor = new SQLASTOutputVisitor(output, DbType.postgresql);

575

stmt.accept(visitor);

576

String postgresqlSql = visitor.getSql();

577

```

578

579

### Cross-Database SQL Translation

580

581

```java

582

// Oracle to MySQL translation

583

String oracleSql = "SELECT * FROM users WHERE ROWNUM <= 10";

584

String mysqlSql = SQLUtils.translateOracleToMySql(oracleSql);

585

// Result: SELECT * FROM users LIMIT 10

586

587

// Format for different databases

588

String baseSql = "select id,name from users where active=1";

589

String mysqlFormatted = SQLUtils.formatMySql(baseSql, new FormatOption(true, true));

590

String oracleFormatted = SQLUtils.formatOracle(baseSql, new FormatOption(true, true));

591

String pgFormatted = SQLUtils.formatPostgreSQL(baseSql, new FormatOption(true, true));

592

```

593

594

This comprehensive SQL processing framework provides enterprise-grade capabilities for parsing, analyzing, transforming, and generating SQL across multiple database platforms with full programmatic control over SQL structure and formatting.