[+/-]
You can use MySQL Shell to manipulate not just JSON documents, but also relational tables.
In MySQL, each relational table is associated with a particular
storage engine. The examples in this section use
InnoDB
tables in the
world_x
database.
Confirm the Schema
To show the value that is assigned to the schema variable, type
db
.
mysql-js> db
If the schema value is not Schema:world_x
, then
set the db
variable as follows:
mysql-js> \use world_x
Show All Tables
To display all relational tables in the world_x
database, use the getTables()
method on the
schema object.
mysql-js> db.getTables()
{
"city": <Table:city>,
"country": <Table:country>,
"countrylanguage": <Table:countrylanguage>
}
Basic Table Operations
Basic operations scoped by tables include:
Operation form | Description |
---|---|
db. |
The insert() method inserts one or more records into the named table. |
db. |
The select() method returns some or all records in the named table. |
db. |
The update() method updates records in the named table. |
db. |
The delete() method deletes one or more records from the named table. |
Related Information
See Working with Relational Tables for a general overview.
CRUD EBNF Definitions provides a complete list of operations.
See Section 20.3.1, “Import Database Sample” for instructions on setting up the
world_x
database sample.