Package com.mysql.cj.xdevapi
Interface Schema
- All Superinterfaces:
DatabaseObject
- All Known Implementing Classes:
SchemaImpl
public interface Schema extends DatabaseObject
A client-side representation of a database schema. Provides access to the schema contents.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Schema.CreateCollectionOptions
Defines options to be passed tocreateCollection(String, CreateCollectionOptions)
.static class
Schema.ModifyCollectionOptions
Defines options to be passed tomodifyCollection(String, ModifyCollectionOptions)
.static class
Schema.Validation
Validation options to be passed tocreateCollection(String, CreateCollectionOptions)
ormodifyCollection(String, ModifyCollectionOptions)
.Nested classes/interfaces inherited from interface com.mysql.cj.xdevapi.DatabaseObject
DatabaseObject.DbObjectStatus, DatabaseObject.DbObjectType
-
Method Summary
Modifier and Type Method Description Collection
createCollection(java.lang.String name)
Create a new collection.Collection
createCollection(java.lang.String name, boolean reuseExisting)
Create a new collection if it does not already exist on the server.Collection
createCollection(java.lang.String collectionName, Schema.CreateCollectionOptions options)
Create a new collection.void
dropCollection(java.lang.String collectionName)
Drop the collection from this schema.Collection
getCollection(java.lang.String name)
Retrieve a reference to the named collection.Collection
getCollection(java.lang.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(java.lang.String name)
Retrieve a reference to the named collection using the table API.java.util.List<Collection>
getCollections()
Retrieve the set of collections existing in this schema.java.util.List<Collection>
getCollections(java.lang.String pattern)
Retrieve the set of collections existing in this schema and matching the given pattern.Table
getTable(java.lang.String name)
Retrieve a reference to the named table.Table
getTable(java.lang.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.java.util.List<Table>
getTables()
Retrieve the set of tables existing in this schema.java.util.List<Table>
getTables(java.lang.String pattern)
Retrieve the set of tables existing in this schema and matching the given pattern.void
modifyCollection(java.lang.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 Details
-
getCollections
java.util.List<Collection> getCollections()Retrieve the set of collections existing in this schema.- Returns:
- list of
Collection
objects
-
getCollections
Retrieve the set of collections existing in this schema and matching the given pattern.- Parameters:
pattern
- match pattern- Returns:
- list of
Collection
objects
-
getTables
java.util.List<Table> getTables()Retrieve the set of tables existing in this schema.- Returns:
- list of
Table
objects
-
getTables
Retrieve the set of tables existing in this schema and matching the given pattern.- Parameters:
pattern
- match pattern- Returns:
- list of
Table
objects
-
getCollection
Retrieve a reference to the named collection.- Parameters:
name
- collection name- Returns:
Collection
-
getCollection
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 namerequireExists
- true if required to exist- Returns:
Collection
-
getCollectionAsTable
Retrieve a reference to the named collection using the table API.- Parameters:
name
- collection name- Returns:
Table
-
getTable
Retrieve a reference to the named table.- Parameters:
name
- table name- Returns:
Table
-
getTable
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 namerequireExists
- true if required to exist- Returns:
Table
-
createCollection
Create a new collection.- Parameters:
name
- collection name- Returns:
Collection
-
createCollection
Create a new collection if it does not already exist on the server.- Parameters:
name
- collection namereuseExisting
- true if allowed to reuse- Returns:
Collection
-
createCollection
Collection createCollection(java.lang.String collectionName, Schema.CreateCollectionOptions options)Create a new collection.- Parameters:
collectionName
- collection nameoptions
- reuseExisting, validation level and JSON schema options- Returns:
Collection
-
modifyCollection
Modify the schema validation of a collection.- Parameters:
collectionName
- collection nameoptions
- validation level and JSON schema options
-
dropCollection
void dropCollection(java.lang.String collectionName)Drop the collection from this schema.- Parameters:
collectionName
- name of collection to drop
-