On this page

EXPAND

Core command

Replaces the * of the last query with the real column names, without running it.

Syntax

EXPAND

Examples

SELECT * FROM CUSTOMER;
EXPAND;
//
SELECT c.*, o.ID FROM CUSTOMER c JOIN ORDERS o ON o.CUSTOMER_ID = c.ID;
EXPAND;

Details

A rewrite, never a run

EXPAND never runs the query. On success, the rewritten query becomes the last query: // and SHOW QUERY show it, and / runs it. When the query cannot be expanded (a form that is not supported, a table that cannot be found, an ambiguous alias, or no * to expand), the last query stays exactly as it was and the reason is printed.

Supported forms

  • SELECT * FROM <table>, with or without a schema;
  • alias.*, with or without AS, including across a chain of JOIN;
  • a bare * only when the query reads exactly one table (no JOIN).

Never changed: COUNT(*), a multiplication (a*b), and any * inside a string or a comment. Only a * or alias.* that is a whole item of the select list is expanded.

Not supported

A subquery or a common table expression (WITH) as the FROM source, and a bare * over several tables, whose column order and duplicate names cannot be reproduced reliably: write alias.* instead.

Used in these how-tos

Last modified in release 5.5.0.

Found something wrong or unclear on this page? , with the page address.