MySQL Shell API  8.0.17
Unified development interface for MySQL Products
Methods | List of all members
Table Class Reference

Represents a Table on an Schema, retrieved with a session created using mysqlx module. More...

Methods

TableInsert insert ()
 Creates TableInsert object to insert new records into the table. More...
 
TableInsert insert (List columns)
 
TableInsert insert (String col1, String col2,...)
 
TableSelect select ()
 Creates a TableSelect object to retrieve rows from the table. More...
 
TableSelect select (List columns)
 
TableUpdate update ()
 Creates a record update handler. More...
 
TableDelete delete ()
 Creates a record deletion handler. More...
 
Bool isView ()
 Indicates whether this Table object represents a View on the database. More...
 
Integer count ()
 Returns the number of records in the table.
 
- Methods inherited from DatabaseObject
String getName ()
 
Object getSession ()
 Returns the Session object of this database object.

Returns
The Session object used to get to this object.
More...
 
Object getSchema ()
 Returns the Schema object of this database object.

Returns
The Schema object used to get to this object.
More...
 
Bool existsInDatabase ()
 Verifies if this object exists in the database.

Returns
A boolean indicating if the object still exists on the database.

 

Additional Inherited Members

- Properties inherited from DatabaseObject
String name
 The name of this database object.
 
Object session
 The Session object of this database object.
 
Object schema
 The Schema object of this database object.
 

Detailed Description

Represents a Table on an Schema, retrieved with a session created using mysqlx module.

Member Function Documentation

◆ insert() [1/3]

TableInsert insert ( )

Creates TableInsert object to insert new records into the table.

Returns
A TableInsert object.

The TableInsert class has other functions that allow specifying the way the insertion occurs.

The insertion is done when the execute method is called on the handler.

See also
TableInsert

◆ insert() [2/3]

TableInsert insert ( List  columns)

Returns
A TableInsert object.

The TableInsert class has other functions that allow specifying the way the insertion occurs.

The insertion is done when the execute method is called on the handler.

See also
TableInsert

◆ insert() [3/3]

TableInsert insert ( String  col1,
String  col2,
  ... 
)

Returns
A TableInsert object.

The TableInsert class has other functions that allow specifying the way the insertion occurs.

The insertion is done when the execute method is called on the handler.

See also
TableInsert

◆ select() [1/2]

TableSelect select ( )

Creates a TableSelect object to retrieve rows from the table.

Full Syntax

Table.select(...)
[.where(expression)]
[.groupBy(...)[.having(condition)]]
[.orderBy(...)]
[.limit(numberOfRows)[.offset(numberOfRows)]]
[.lockShared(lockContention)|.lockExclusive(lockContention)]
[.bind(name, value)]
.execute()

.select()

Defines the columns that will be retrieved from the Table.

To define the column list either use a list object containing the column definition or pass each column definition on a separate parameter

.where(...)

If used, only those rows satisfying the expression will be retrieved

.groupBy(...)

.having(condition)

If used the TableSelect operation will only consider the records matching the established criteria.

.orderBy(...)

Overloads
  • orderBy(sortCriterion[, sortCriterion, ...])"); @li orderBy(sortCriteria)"); If used the records will be sorted with the defined criteria.

The elements of sortExprStr list are strings defining the column name on which the sorting will be based.

The format is as follows: columnIdentifier [ ASC | DESC ]

If no order criteria is specified, ascending will be used by default.

.limit(numberOfRows)

If used, the operation will return at most numberOfRows rows.

.offset(numberOfRows)

.lockShared(lockContention)

When this function is called, the selected rows will be locked for write operations, they may be retrieved on a different session, but no updates will be allowed.

The acquired locks will be released when the current transaction is committed or rolled back.

The lockContention parameter defines the behavior of the operation if another session contains an exclusive lock to matching rows.

The lockContention can be specified using the following constants:

  • mysqlx.LockContention.DEFAULT
  • mysqlx.LockContention.NOWAIT
  • mysqlx.LockContention.SKIP_LOCKED

The lockContention can also be specified using the following string literals (no case sensitive):

  • 'DEFAULT'
  • 'NOWAIT'
  • 'SKIP_LOCKED'

If no lockContention or the default is specified, the operation will block if another session already holds an exclusive lock on matching rows until the lock is released.

If lockContention is set to NOWAIT and another session already holds an exclusive lock on matching rows, the operation will not block and an error will be generated.

If lockContention is set to SKIP_LOCKED and another session already holds an exclusive lock on matching rows, the operation will not block and will return only those rows not having an exclusive lock.

This operation only makes sense within a transaction.

.lockExclusive(lockContention)

When this function is called, the selected rows will be locked for read operations, they will not be retrievable by other session.

The acquired locks will be released when the current transaction is committed or rolled back.

The lockContention parameter defines the behavior of the operation if another session contains a lock to matching rows.

The lockContention can be specified using the following constants:

  • mysqlx.LockContention.DEFAULT
  • mysqlx.LockContention.NOWAIT
  • mysqlx.LockContention.SKIP_LOCKED

The lockContention can also be specified using the following string literals (no case sensitive):

  • 'DEFAULT'
  • 'NOWAIT'
  • 'SKIP_LOCKED'

If no lockContention or the default is specified, the operation will block if another session already holds a lock on matching rows until the lock is released.

If lockContention is set to NOWAIT and another session already holds a lock on matching rows, the operation will not block and an error will be generated.

If lockContention is set to SKIP_LOCKED and another session already holds a lock on matching rows, the operation will not block and will return only those rows not having an exclusive lock.

This operation only makes sense within a transaction.

.bind(name, value)

Binds a value to a specific placeholder used on this operation.

An error will be raised if the placeholder indicated by name does not exist.

This function must be called once for each used placeholder or an error will be raised when the execute method is called.

.execute()

Executes the select operation with all the configured options.

◆ select() [2/2]

TableSelect select ( List  columns)

Parameters
columnsA list of strings defining the columns to be retrieved.
Returns
A TableSelect object.

This function creates a TableSelect object which is a record selection handler.

This handler will retrieve only the columns specified on the columns list for each included record.

Each column on the list should be a string identifying the column name, alias is supported.

The TableSelect class has several functions that allow specifying what records should be retrieved from the table, if a searchCondition was specified, it will be set on the handler.

The selection will be returned when the execute function is called on the handler.

See also
TableSelect

◆ update()

TableUpdate update ( )

Creates a record update handler.

Returns
A TableUpdate object.

This function creates a TableUpdate object which is a record update handler.

The TableUpdate class has several functions that allow specifying the way the update occurs, if a searchCondition was specified, it will be set on the handler.

The update is done when the execute function is called on the handler.

See also
TableUpdate

◆ delete()

TableDelete delete ( )

Creates a record deletion handler.

Returns
A TableDelete object.

This function creates a TableDelete object which is a record deletion handler.

The TableDelete class has several functions that allow specifying what should be deleted and how, if a searchCondition was specified, it will be set on the handler.

The deletion is done when the execute function is called on the handler.

See also
TableDelete

◆ isView()

Bool isView ( )

Indicates whether this Table object represents a View on the database.

Returns
True if the Table represents a View on the database, False if represents a Table.