In MySQL Shell, you can create new collections, get a list of the existing collections in a schema, and remove an existing collection from a schema. Collection names are case-sensitive and each collection name must be unique.
To show the value that is assigned to the schema variable,
If the schema value is not
then set the
db variable as follows:
mysql-py> \use world_x
To create a new collection in an existing schema, use the
create_collection() method. The following
example creates a collection called flags in the
The method returns a collection object.
To display all collections in the
database, use the
get_collections() method. Collections
returned by the server you are currently connected to appear
mysql-py> db.get_collections() [ <Collection:countryinfo>, <Collection:flags> ]
To drop an existing collection from a database, use the
drop_collection() method. For example, to
drop the flags collection from the
mysql-py> session.drop_collection("world_x", "flags")
drop_collection() method is also used
in MySQL Shell to drop a relational table from a database.
See Collection Objects for more examples.