Class SqlSchemaNames

java.lang.Object
io.micronaut.data.model.query.builder.sql.SqlSchemaNames

@Internal public final class SqlSchemaNames extends Object
Renders schema names as SQL identifiers, and builds the Oracle statement that creates a schema.
Since:
5.3.0
  • Method Details

    • render

      public static String render(Dialect dialect, String name)
      Renders a schema name as a dialect-compatible SQL identifier. Simple identifiers are left unquoted to preserve the case-folding behavior of existing applications. All other names are quoted and their delimiters escaped. On Oracle, every name is quoted in upper case, the form Oracle folds an unquoted name to, so that names starting with _ and reserved words, including ones added by later releases, work too. The input is always treated as a logical name; SQL quoting supplied by a caller is not interpreted.
      Parameters:
      dialect - The SQL dialect
      name - The logical schema name
      Returns:
      The safely rendered identifier
      Throws:
      IllegalArgumentException - If the name is null, empty, or contains a NUL character
    • oracleCreateSchemaStatement

      public static String oracleCreateSchemaStatement(String name)
      Builds the Oracle statement that creates a schema. An Oracle schema is a user, so the statement creates a user without credentials (NO AUTHENTICATION) and grants it quota on the database default tablespace. An existing user is accepted, so the statement can run on every startup, but a role of the same name, which Oracle reports with the same error (ORA-01920), is not.
      Parameters:
      name - The logical schema name
      Returns:
      The PL/SQL block creating the schema
      Throws:
      IllegalArgumentException - If the name is null, empty, or contains a NUL character
    • oracleCreateSchemaStatement

      public static String oracleCreateSchemaStatement(String identifier, boolean quoted)
      Builds the Oracle statement that creates a schema from an identifier that is already rendered, such as one that contains property placeholders resolved later.
      Parameters:
      identifier - The SQL identifier of the schema
      quoted - Whether the identifier is quoted, so that its case is kept, or folds to upper case
      Returns:
      The PL/SQL block creating the schema