com.mysql.cj.xdevapi

## Interface Schema

All Superinterfaces:
  DatabaseObject

    public interface Schema
    extends DatabaseObject

A client-side representation of a database schema. Provides access to the schema contents.

### Nested Class Summary

Nested Classes
`static class` `Schema.CreateCollectionOptions` Defines options to be passed to `createCollection(String, CreateCollectionOptions)`.
`static class` `Schema.ModifyCollectionOptions` Defines options to be passed to `modifyCollection(String, ModifyCollectionOptions)`.
`static class` `Schema.Validation` Validation options to be passed to `createCollection(String, CreateCollectionOptions)` or `modifyCollection(String, ModifyCollectionOptions)`.

### Nested classes/interfaces inherited from interface com.mysql.cj.xdevapi.DatabaseObject

`DatabaseObject.DbObjectStatus, DatabaseObject.DbObjectType`

### Method Summary

All Methods Instance Methods Abstract Methods
`Collection` `createCollection(String name)` Create a new collection.
`Collection` `createCollection(String name, boolean reuseExisting)` Create a new collection if it does not already exist on the server.
`Collection` `createCollection(String collectionName, Schema.CreateCollectionOptions options)` Create a new collection.
`void` `dropCollection(String collectionName)` Drop the collection from this schema.
`Collection` `getCollection(String name)` Retrieve a reference to the named collection.
`Collection` `getCollection(String name, boolean requireExists)` Retrieve a reference to the named collection hinting that an exception should be thrown if the collection is not known to the server.
`Table` `getCollectionAsTable(String name)` Retrieve a reference to the named collection using the table API.
`List<Collection>` `getCollections()` Retrieve the set of collections existing in this schema.
`List<Collection>` `getCollections(String pattern)` Retrieve the set of collections existing in this schema and matching the given pattern.
`Table` `getTable(String name)` Retrieve a reference to the named table.
`Table` `getTable(String tableName, boolean requireExists)` Retrieve a reference to the named table hinting that an exception should be thrown if the collection is not known to the server.
`List<Table>` `getTables()` Retrieve the set of tables existing in this schema.
`List<Table>` `getTables(String pattern)` Retrieve the set of tables existing in this schema and matching the given pattern.
`void` `modifyCollection(String collectionName, Schema.ModifyCollectionOptions options)` Modify the schema validation of a collection.

### Methods inherited from interface com.mysql.cj.xdevapi.DatabaseObject

`existsInDatabase, getName, getSchema, getSession`

### Method Detail

#### getCollections

    List<Collection> getCollections()

Retrieve the set of collections existing in this schema.

Returns:
  list of `Collection` objects

#### getCollections

    List<Collection> getCollections(String pattern)

Retrieve the set of collections existing in this schema and matching the given pattern.

Parameters:
  `pattern` - match pattern
Returns:
  list of `Collection` objects

#### getTables

    List<Table> getTables()

Retrieve the set of tables existing in this schema.

Returns:
  list of `Table` objects

#### getTables

    List<Table> getTables(String pattern)

Retrieve the set of tables existing in this schema and matching the given pattern.

Parameters:
  `pattern` - match pattern
Returns:
  list of `Table` objects

#### getCollection

    Collection getCollection(String name)

Retrieve a reference to the named collection.

Parameters:
  `name` - collection name
Returns:
  `Collection`

#### getCollection

    Collection getCollection(String name,
                             boolean requireExists)

Retrieve a reference to the named collection hinting that an exception should be thrown if the collection is not known to the server.

Parameters:
  `name` - collection name
  `requireExists` - true if required to exist
Returns:
  `Collection`

#### getCollectionAsTable

    Table getCollectionAsTable(String name)

Retrieve a reference to the named collection using the table API.

Parameters:
  `name` - collection name
Returns:
  `Table`

#### getTable

    Table getTable(String name)

Retrieve a reference to the named table.

Parameters:
  `name` - table name
Returns:
  `Table`

#### getTable

    Table getTable(String tableName,
                   boolean requireExists)

Retrieve a reference to the named table hinting that an exception should be thrown if the collection is not known to the server.

Parameters:
  `tableName` - table name
  `requireExists` - true if required to exist
Returns:
  `Table`

#### createCollection

    Collection createCollection(String name)

Create a new collection.

Parameters:
  `name` - collection name
Returns:
  `Collection`

#### createCollection

    Collection createCollection(String name,
                                boolean reuseExisting)

Create a new collection if it does not already exist on the server.

Parameters:
  `name` - collection name
  `reuseExisting` - true if allowed to reuse
Returns:
  `Collection`

#### createCollection

    Collection createCollection(String collectionName,
                                Schema.CreateCollectionOptions options)

Create a new collection.

Parameters:
  `collectionName` - collection name
  `options` - reuseExisting, validation level and JSON schema options
Returns:
  `Collection`

#### modifyCollection

    void modifyCollection(String collectionName,
                          Schema.ModifyCollectionOptions options)

Modify the schema validation of a collection.

Parameters:
  `collectionName` - collection name
  `options` - validation level and JSON schema options

#### dropCollection

    void dropCollection(String collectionName)

Drop the collection from this schema.

Parameters:
  `collectionName` - name of collection to drop

Copyright © 2016, 2026, Oracle and/or its affiliates.