Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SQL (query)

Synopsis

SQL alias query_text

SQL alias SHOW TABLES
SQL alias SHOW VIEWS
SQL alias SHOW FUNCTIONS
SQL alias DESCRIBE table_name

Description

Executes a SQL query or schema discovery command against an external database connection. The alias identifies which connection to use (established with SQL CONNECT).

Raw SQL passthrough: Any SQL text after the alias is sent directly to the external database. The results are displayed as a formatted table. This supports SELECT, INSERT, UPDATE, DELETE, DDL, and any other SQL the target database accepts.

Schema discovery commands provide a portable way to explore the database schema without writing database-specific SQL:

CommandDescription
SHOW TABLESLists user tables in the database
SHOW VIEWSLists user views in the database
SHOW FUNCTIONSLists functions and stored procedures
DESCRIBE table_nameShows columns, data types, and nullability for a table

The schema discovery commands query information_schema internally and work consistently across PostgreSQL, Oracle, and SQL Server.

Parameters

alias
The connection alias established with SQL CONNECT.
query_text
Any valid SQL for the target database. Sent as-is to the database engine.
table_name (DESCRIBE only)
The name of the table or view to describe.

Examples

Query data

SQL source SELECT * FROM users WHERE active = true LIMIT 10;

List tables

SQL source SHOW TABLES;

List views

SQL source SHOW VIEWS;

Describe a table

SQL source DESCRIBE users;

Insert data

SQL source INSERT INTO audit_log (action, timestamp) VALUES ('export', NOW());

Run aggregate queries

SQL source SELECT department, COUNT(*) AS headcount
  FROM employees
  GROUP BY department
  ORDER BY headcount DESC;

From the command line

-- Shell command:
-- mxcli sql --driver postgres --dsn 'postgres://...' "SELECT * FROM users"

See Also

SQL CONNECT, SQL DISCONNECT, SQL GENERATE CONNECTOR, IMPORT FROM