final class LoadTable
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

LOAD DATA and LOAD XML: reads rows from a file into a table.

Mirrors the server's PT_load_table with its sql_exchange. The facts follow MYSQL-LOAD-001. A clause written twice in the field or line options is kept twice. Source: https://dev.mysql.com/doc/refman/8.4/en/load-data.html, https://dev.mysql.com/doc/refman/8.4/en/load-xml.html.

Reading a LOAD DATAdoctest
$load = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("LOAD DATA INFILE 'f' REPLACE INTO TABLE t FIELDS TERMINATED BY ',' IGNORE 1 LINES (a, @b) SET c = @b * 2");
    [$load->statement->duplicates, count($load->statement->columns), $load->toString()] // => [\SqlSemantics\Platform\MySql\Statement\Dml\DuplicateHandling::Replace, 2, "LOAD DATA INFILE 'f' REPLACE INTO TABLE t COLUMNS TERMINATED BY ',' IGNORE 1 LINES (a, @b) SET c = @b * 2"]

Properties§

public list<FieldOption> $fields
public list<LineOption> $lines
public list<ColumnUse|UserVariable> $columns
public list<Assignment> $assignments
public LoadFormat $format
public LoadLock|null $lock
public LoadInput $input
public DuplicateHandling|null $duplicates
public WriteTarget $table
public CharsetName|null $charset = null
public Text|null $compression = null
public Text|null $rowTag = null
public Numeral|null $ignored = null
public BulkOptions|null $bulk = null

Methods§

public function __construct(
    public LoadFormat $format,
    public LoadLock|null $lock,
    public LoadInput $input,
    public DuplicateHandling|null $duplicates,
    public WriteTarget $table,
    public CharsetName|null $charset = null,
    public Text|null $compression = null,
    public Text|null $rowTag = null,
    list<FieldOption> $fields = [],
    list<LineOption> $lines = [],
    public Numeral|null $ignored = null,
    list<ColumnUse|UserVariable> $columns = [],
    list<Assignment> $assignments = [],
    public BulkOptions|null $bulk = null,
)

Parameters

$formatLoadFormatDATA or XML
$lockLoadLock|nullThe scheduling modifier
$inputLoadInputWhat is read
$duplicatesDuplicateHandling|nullWhat a row that duplicates a unique key does
$tableWriteTargetThe table the rows are written to; it has no correlation name
$charsetCharsetName|nullThe character set of the file
$compressionText|nullThe compression algorithm of the files (9.x bulk load)
$rowTagText|nullThe XML element of a row, `ROWS IDENTIFIED BY`
$fieldslist<FieldOption>The FIELDS options
$lineslist<LineOption>The LINES options
$ignoredNumeral|nullThe number of lines or rows skipped at the start
$columnslist<ColumnUse|UserVariable>The columns and user variables the fields are read into
$assignmentslist<Assignment>The SET assignments
$bulkBulkOptions|nullThe options of a bulk load

Throws

InvalidConstruction When the table has a correlation name or a member of a list is of the wrong class
Calls 6
public function deriveStatement(Derivation $derivation): void

Derives the table, the columns and the assignments; the statement returns no rows.

Parameters

$derivationDerivation
Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 3

Test cases 2§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2

Relations§

Instantiated in 1
Type checks 1
Type declarations 2