From 6fe33241884ceca771de352547ae92d44a60f6eb Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Thu, 12 Nov 2026 02:52:33 +0700 Subject: [PATCH] docs(features): DELIMITER lines, COPY rows, IF ... ELSE and join conditions --- features/autocomplete.mdx | 15 +++++++++++++++ features/compare-sync.mdx | 2 +- features/import-export.mdx | 2 ++ features/sql-editor.mdx | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/features/autocomplete.mdx b/features/autocomplete.mdx index e4d2281..6195531 100644 --- a/features/autocomplete.mdx +++ b/features/autocomplete.mdx @@ -110,6 +110,21 @@ SELECT price * qty AS line_total FROM items ORDER BY li| -- line_total `SET` and an `INSERT` column list offer the columns of the table the statement writes, never those of a table its FROM or SELECT reads, also inside a `WITH` body. +## Join conditions + +Right after the `ON` of a join, the foreign keys between the joined table and the tables before it come first, each as a whole condition: + +```sql +SELECT * FROM orders o JOIN customers c ON | -- o.customer_id = c.id +``` + +- A key in either direction counts, and the earlier table's column comes first. +- A key over several columns is one condition, its pairs joined with `AND`. +- The nearest earlier table comes first. A table joined after the cursor, a derived table and a `WITH` table give none. +- The alias names a table when it has one, otherwise the table name as you wrote it. + +The keys are read once per table, on engines that report foreign keys. After `o.`, or once the condition has begun, the list offers columns as before. + ## Aliases, subqueries and CTEs An alias followed by `.` gives that table's columns. A derived table or a `WITH` table gives the columns its own query produces: diff --git a/features/compare-sync.mdx b/features/compare-sync.mdx index 251ef84..1bd9164 100644 --- a/features/compare-sync.mdx +++ b/features/compare-sync.mdx @@ -137,7 +137,7 @@ A saved script is written for the target engine's own client, so each statement | SQL Server | `;` and a `GO` line | `;` and a `GO` line | | PostgreSQL, SQLite and every other engine | `;` | `;` | -Run the Oracle script in SQL*Plus or SQLcl, the Dameng script in DISQL, the MySQL script in the `mysql` client, and the SQL Server script in `sqlcmd` or SQL Server Management Studio. The query editor reads the Oracle, PostgreSQL and SQLite forms as saved, but sends a `DELIMITER` or `GO` line to the server as a statement: remove those lines before running a MySQL or SQL Server script there. +Run the Oracle script in SQL*Plus or SQLcl, the Dameng script in DISQL, the MySQL script in the `mysql` client, and the SQL Server script in `sqlcmd` or SQL Server Management Studio. The query editor runs each of these forms as saved, its `DELIMITER` and `GO` lines included. SQL*Plus ends a plain statement at a blank line and reports `SP2-0734: unknown command` for the rest of it. When a view's definition holds a blank line, run `SET SQLBLANKLINES ON` before the script. diff --git a/features/import-export.mdx b/features/import-export.mdx index df0f33c..b900143 100644 --- a/features/import-export.mdx +++ b/features/import-export.mdx @@ -320,6 +320,8 @@ The import runs on the connection's own session, and afterwards puts back the se On SQL Server a file that holds a `GO` line runs a batch at a time, cut at its `GO` lines the way `sqlcmd` cuts it, so every count and failure here is a batch rather than a statement. A file with no `GO` line runs a statement at a time. See [Scripts and batches](/databases/mssql#scripts-and-batches). +On PostgreSQL a file stops at a `COPY ... FROM STDIN`, the form `pg_dump` writes table rows in by default, before sending it, and the error names its line: TablePro cannot send the rows that follow it, and never runs them as SQL. Restore such a file with `psql`, or dump it again with `pg_dump --inserts`. The `\restrict` and `\unrestrict` lines a current `pg_dump` writes run nothing. On MySQL and MariaDB a `DELIMITER` line is read as the `mysql` client reads it: only as the first thing on its line, before any statement text. + SQL Server SQL imports do not automatically commit or roll back after a file batch runs, even with **Wrap in transaction** selected and even without a `GO` line. A batch can change which transaction is open. Read the completion message: if a transaction remains open, commit or roll it back on this connection. This also applies after a successful import. Imports into a selected table from CSV, JSON, or XLSX use the row-import transaction options instead. Skip and Continue collects up to 1,000 failures with their line numbers and messages, and the summary counts successes against failures behind a **Copy Details** button. **Save Report…** writes them all to a CSV with a line, a statement and the database's own error per row, so a large import's failures can be sorted and searched rather than scrolled. An error that stops the import shows the line, the database's own message, and the failing statement, with the dialog still open behind it, ready for a changed setting and another run. The alert shows the first 10,000 characters of a longer statement and the first five errors of a batch that raised more, and **Copy Details** copies all of them. diff --git a/features/sql-editor.mdx b/features/sql-editor.mdx index 7517ff3..0f283ae 100644 --- a/features/sql-editor.mdx +++ b/features/sql-editor.mdx @@ -102,6 +102,9 @@ The editor marks which statement it is about to send. - A run button takes the same [safe mode](/features/safe-mode) checks and [parameter](/features/query-parameters) prompts as any other run, and dims while a query is running. - VoiceOver reads each button as a button naming the line its statement starts on. - A `BEGIN … END` body counts as one statement, so a trigger or stored procedure gets one button rather than one per line inside it. `BEGIN;` and `BEGIN TRANSACTION;` are statements of their own. On Oracle, a whole [PL/SQL block or unit](/databases/oracle#pl%2Fsql) is one statement. +- On SQL Server an `IF` stays one statement through its `ELSE`, even when a `;` ends the `IF`'s branch: `IF @a = 1 SELECT 1; ELSE SELECT 2;`. +- On MySQL and MariaDB a `DELIMITER //` line runs nothing, and `//` then ends a statement, as the `mysql` client reads a script. The line counts only as the first thing on its line, before any statement text. A `;` still ends a statement outside a routine body. +- On PostgreSQL the rows after `COPY ... FROM STDIN`, up to the line holding only `\.`, belong to the `COPY` and never run as SQL. The editor cannot send them, so the `COPY` stops with a message that no rows were sent. Load them with `psql`, or write the rows as `INSERT` statements. The `\restrict` and `\unrestrict` lines `pg_dump` writes run nothing. Turn either marker off in **Settings > Editor** with **Highlight current statement** and **Run button beside each statement**.