Shape / columns · All operations

Reorder columns

A variant of Choose and rename columns

Change the order of the columns without changing which columns there are.

Status

In arcform

Runs as a SQL step

arcform carries it as a sql: step today.

The DuckDB step

Reorder columns without changing which there are

It reads the orders table the proofs share. Create it first:

SQL
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);

Then run the statement:

SQL
CREATE TEMP TABLE result AS
SELECT amount, customer, * EXCLUDE (amount, customer) FROM orders;
SELECT * FROM result LIMIT 3;
SELECT CASE WHEN ((SELECT list(column_name) FROM (DESCRIBE result)) = ['amount', 'customer', 'order_id', 'region', 'order_date', 'product', 'tags', 'meta'] AND (SELECT count(*) FROM result) = 10) THEN 'as expected' ELSE error('amount and customer were not moved to the front of the same eight columns') END AS verdict;
  • It needs nothing installed beyond DuckDB itself.
  • The statement checks its own result and raises an error when it is wrong: “amount and customer were not moved to the front of the same eight columns”.
  • It passed on DuckDB v2.0.0 (Cyanoptera) d54cbbe3df.

What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

Duckle (1)
EasyMorph (1)
KNIME Analytics Platform (1)
OpenRefine (4)
Power Query M (1)
RapidMiner Studio (2)
Tableau Prep (1)
  • Reorder fieldsread 2026-09-27

    Drag fields into a new order; the order persists to output

Trifacta (2)
  • Move Transformread 2026-09-27

    Move columns before or after another column

  • Move columnsread 2026-09-27

    Move columns before or after another column

VisiData (6)
  • slide-leftread 2026-09-23

    Move current column one position left

  • slide-left-nread 2026-09-23

    Move current column N positions left

  • slide-leftmostread 2026-09-23

    Move current column to the left end of its section

  • slide-rightread 2026-09-23

    Move current column one position right

  • slide-right-nread 2026-09-23

    Move current column N positions right

  • slide-rightmostread 2026-09-23

    Move current column to the right end of its section

Background

In EasyMorph, Reorder columns moves one or more columns to the leftmost position, to the rightmost position, or after a particular column.[1] In KNIME, the Column Resorter node changes the order of the input columns, and can also sort the columns by name.[2] Under Christopher J. Date's definition of first normal form, a table has no specific left-to-right ordering of its columns.[3]

When to use it

In EasyMorph, the use cases given for Reorder columns are grouping columns together and ensuring a particular order of columns before exporting to a file.[1] In DuckDB, traditional set operations such as UNION combine queries by column position, and the result uses the column names from the first query.[4] In DuckDB, UNION BY NAME combines columns by name instead of by position and does not require the inputs to have the same number of columns.[4] In DuckDB, loading a CSV file with COPY needs a table whose schema matches the order of the columns in the file.[5]

The method

In KNIME, the Column Resorter can shift columns one step left or right, or move them to the beginning or end of the table.[2] In KNIME, the Column Resorter inserts new and previously unknown columns at the position of a placeholder, Any unknown columns, which can be positioned like any column.[2] Decide where columns you have not seen yet should land: name the columns that must lead, and let the rest follow in their existing order. (Meridian's view)

Compared with the alternatives

Under Christopher J. Date's definition, a table in first normal form also has no specific top-to-bottom ordering of its rows.[3] Reordering columns is the column-wise counterpart of sorting rows: neither changes what the table holds, only how it is read and how positional tools see it. (Meridian's view)

Sources

  1. [1]REORDER COLUMNS [EasyMorph Help]documentation
  2. [2]Column Resorterdocumentation
  3. [3]First normal form - Wikipediasecondary source
  4. [4]Set Operations – DuckDBdocumentation
  5. [5]CSV Import – DuckDBdocumentation