public class MySQLEngine extends AbstractDbEngine implements DbEngine
Constructor and Description |
---|
MySQLEngine()
Create MySQLEngine.
|
Modifier and Type | Method and Description |
---|---|
boolean |
analyzeAfterBatchOperation()
Return true.
|
private void |
appendList(java.lang.StringBuilder sb,
java.util.Collection<java.lang.String> items) |
boolean |
caseInsensitiveComparison()
Returns TRUE.
|
boolean |
dropForeignKeysUsedInIndex()
When dropping an index, must foreign keys that uses the same columns also be
dropped (before dropping the index)?
|
java.lang.String |
getAnalyzeTableSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Generate
analyze table <catalog>. |
java.lang.String |
getApproximateRowCountSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Get an SQL statement that returns an approximate count for the number
of rows in the given table.
|
java.lang.String |
getCaseSensitiveVarchar(int length)
Return
varchar(length) CHARACTER SET utf8 COLLATE utf8_bin . |
java.lang.String |
getCatalogName(java.lang.String catalog,
java.lang.String schema)
Generates a catalog name by combining the catalog and
schema name (catalog_schema).
|
java.lang.String |
getCreateForeignKeySql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
java.util.Set<java.lang.String> columns,
java.lang.String refTable,
java.util.Set<java.lang.String> refColumns)
Generate
alter table schema.table add constraint name
foreign key (columns) references refTable (refColumns) |
java.lang.String |
getCreateIndexSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
java.util.Set<java.lang.String> columns,
boolean unique)
Generate
alter table <catalog>. |
java.lang.String |
getCreatePrimaryKeySql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
java.util.Set<java.lang.String> columns)
Generate
alter table catalog.table add primary key (columns) |
java.lang.String |
getCreateSchemaSql(java.lang.String catalog,
java.lang.String schema)
Generate
create schema <catalog> . |
java.lang.String |
getDropForeignKeySql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name)
Generate
alter table <catalog>. |
java.lang.String |
getDropIndexSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
boolean unique)
Generate
drop index <name> on <catalog>. |
java.lang.String |
getDropPrimaryKey(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name)
Generate
alter table catalog.table drop primary key |
java.lang.String |
getInsertAutoIncrementSql(PersistentClass pc)
Return a SQL fragment that can be used in an INSERT INTO statement
to generate an ID for new rows.
|
java.lang.String |
getOptimizeTableSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Generate
optimize table <catalog>. |
java.lang.String |
getQuotedName(java.lang.String name)
Put quotes (`) around the name.
|
java.lang.String |
getSchemaName(java.lang.String catalog,
java.lang.String schema)
Return null.
|
java.lang.String |
ln(java.lang.String value)
Return
LOG(<value>) . |
java.lang.String |
makeSafeCreateTable(java.lang.String sql,
java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Replace "create table" with "create table if not exists"...
|
java.lang.String |
rlike(java.lang.String value,
java.lang.String regexp)
Return
<value> RLIKE <regexp> . |
boolean |
supportColumnAliasInGroupBy()
Returns TRUE.
|
boolean |
supportColumnAliasInHaving()
Returns TRUE.
|
boolean |
supportColumnAliasInOrderBy()
Returns TRUE.
|
boolean |
supportsColumnAliasInWhere()
Returns FALSE.
|
boolean |
useThetaJoin()
Always false.
|
abs, castToDate, checkForInvalidNumberOperation, exp, getCreatePartialIndexSql, getMaxParametersInQuery, inspectSchemaGenerationSQL, isValidColumnName, isValidName, isValidTableName, power, selectOrderByColumnsIfDistinct, useSavePointToContinueTransactionFromSqlFailure
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
abs, castToDate, checkForInvalidNumberOperation, exp, getCreatePartialIndexSql, getMaxParametersInQuery, inspectSchemaGenerationSQL, isValidColumnName, isValidTableName, power, selectOrderByColumnsIfDistinct, useSavePointToContinueTransactionFromSqlFailure
public boolean useThetaJoin()
useThetaJoin
in interface DbEngine
useThetaJoin
in class AbstractDbEngine
public java.lang.String getCatalogName(java.lang.String catalog, java.lang.String schema)
getCatalogName
in interface DbEngine
getCatalogName
in class AbstractDbEngine
catalog
- The catalog name (always not null)schema
- The schema name (always not null)public java.lang.String getSchemaName(java.lang.String catalog, java.lang.String schema)
getSchemaName
in interface DbEngine
getSchemaName
in class AbstractDbEngine
catalog
- The catalog name (always not null)schema
- The schema name (always not null)public java.lang.String getCreateSchemaSql(java.lang.String catalog, java.lang.String schema)
create schema <catalog>
.getCreateSchemaSql
in interface DbEngine
public java.lang.String getCreateIndexSql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, java.util.Set<java.lang.String> columns, boolean unique)
alter table <catalog>.<table> add [unique]
index <name> (<columns>)
.
The schema parameter is not supported.getCreateIndexSql
in interface DbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the index to be createdcolumns
- The name of the columns in the indexunique
- If the index must contain unique values or notpublic boolean dropForeignKeysUsedInIndex()
DbEngine
dropForeignKeysUsedInIndex
in interface DbEngine
dropForeignKeysUsedInIndex
in class AbstractDbEngine
public java.lang.String getDropIndexSql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, boolean unique)
drop index <name> on <catalog>.<table>
.
The schema parameter is not supported.getDropIndexSql
in interface DbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the indexunique
- If the index contains unique values or notpublic java.lang.String getCreateForeignKeySql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, java.util.Set<java.lang.String> columns, java.lang.String refTable, java.util.Set<java.lang.String> refColumns)
alter table schema.table add constraint name
foreign key (columns) references refTable (refColumns)
getCreateForeignKeySql
in interface DbEngine
catalog
- The name of the catalog (database) where the tables are
located, or null if it is located in the current catalogschema
- The name of the schema where the tables are located, or
null if is located in the current schematable
- The name of the foreign key tablename
- The name of the foreign keycolumns
- The columns that make up the foreign keyrefTable
- The table that is referenced by the foreign keyrefColumns
- The columns that are referenced by the foreign keypublic java.lang.String getDropForeignKeySql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name)
alter table <catalog>.<table> drop foreign key <name>
getDropForeignKeySql
in interface DbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the foreign keypublic java.lang.String getCreatePrimaryKeySql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, java.util.Set<java.lang.String> columns)
alter table catalog.table add primary key (columns)
getCreatePrimaryKeySql
in interface DbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the primary keycolumns
- The name of the columns in the primary keypublic java.lang.String getDropPrimaryKey(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name)
alter table catalog.table drop primary key
getDropPrimaryKey
in interface DbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the primary keypublic java.lang.String getInsertAutoIncrementSql(PersistentClass pc)
DbEngine
getInsertAutoIncrementSql
in interface DbEngine
pc
- The persistent classpublic boolean analyzeAfterBatchOperation()
analyzeAfterBatchOperation
in interface DbEngine
public java.lang.String getOptimizeTableSql(java.lang.String catalog, java.lang.String schema, java.lang.String table)
optimize table <catalog>.<table>
.
The schema parameter is not supported.getOptimizeTableSql
in interface DbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the table to optimizeDbEngine.getAnalyzeTableSql(String, String, String)
public java.lang.String getAnalyzeTableSql(java.lang.String catalog, java.lang.String schema, java.lang.String table)
analyze table <catalog>.<table>
.
The schema parameter is not supported.getAnalyzeTableSql
in interface DbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the table to analyzeDbEngine.getOptimizeTableSql(String, String, String)
public java.lang.String makeSafeCreateTable(java.lang.String sql, java.lang.String catalog, java.lang.String schema, java.lang.String table)
makeSafeCreateTable
in interface DbEngine
makeSafeCreateTable
in class AbstractDbEngine
sql
- The original SQLcatalog
- The name of the catalog (database) where the table is
being create, or null if it is located in the current catalogschema
- The name of the schema where the table is being created, or
null if is located in the current schematable
- The name of the table that is being createdpublic boolean caseInsensitiveComparison()
caseInsensitiveComparison
in interface DbEngine
public boolean supportsColumnAliasInWhere()
supportsColumnAliasInWhere
in interface DbEngine
supportsColumnAliasInWhere
in class AbstractDbEngine
public boolean supportColumnAliasInOrderBy()
supportColumnAliasInOrderBy
in interface DbEngine
supportColumnAliasInOrderBy
in class AbstractDbEngine
public boolean supportColumnAliasInGroupBy()
supportColumnAliasInGroupBy
in interface DbEngine
supportColumnAliasInGroupBy
in class AbstractDbEngine
public boolean supportColumnAliasInHaving()
supportColumnAliasInHaving
in interface DbEngine
supportColumnAliasInHaving
in class AbstractDbEngine
public java.lang.String ln(java.lang.String value)
LOG(<value>)
.ln
in interface DbEngine
ln
in class AbstractDbEngine
value
- The value to take the logarithm ofpublic java.lang.String rlike(java.lang.String value, java.lang.String regexp)
<value> RLIKE <regexp>
.rlike
in interface DbEngine
rlike
in class AbstractDbEngine
value
- The left valueregexp
- The regular expression as a stringpublic java.lang.String getCaseSensitiveVarchar(int length)
varchar(length) CHARACTER SET utf8 COLLATE utf8_bin
.getCaseSensitiveVarchar
in interface DbEngine
getCaseSensitiveVarchar
in class AbstractDbEngine
length
- The maximum length that needs to be stored in the columnpublic java.lang.String getQuotedName(java.lang.String name)
getQuotedName
in interface DbEngine
getQuotedName
in class AbstractDbEngine
name
- The name of an object in the databasepublic java.lang.String getApproximateRowCountSql(java.lang.String catalog, java.lang.String schema, java.lang.String table)
DbEngine
getApproximateRowCountSql
in interface DbEngine
getApproximateRowCountSql
in class AbstractDbEngine
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tableprivate void appendList(java.lang.StringBuilder sb, java.util.Collection<java.lang.String> items)