Renaming Tables And Columns in the FROM Clause


The from as well as the join clause allow to assign a new names to the respective table and its columns. Assigning table names is often done to use shorter names in the statement. Naming columns is most often used to names to columns that don’t have a use-defined name yet.

The syntax is quite simple: Each data source in a from or join clause can be followed by the optional keyword as and the new name under which this data source will be known from there on. Optionally, the parenthesized list of new column names follows.

FROM … [[AS] new_name [(<derived column list>)]]

The new names actually replace the old ones in the semantically following clauses (on/using, where, group by, having, window, select).

SELECT b, a
  FROM (VALUES (1, 'a')
       ) t(a, b)

If you like this page, you might also like …

… to subscribe my mailing lists, get free stickers, buy my book or join a training.

Use Cases

Conforming Alternatives

The with clause can also assign new names to columns based on their position.

WITH t (a, b) AS (
  VALUES (1, 'a')
)
SELECT b, a
  FROM t

Compatibility

BigQuery 2026-02-18Db2 (LUW) 12.1.3DuckDB 1.4.0H2 2.4.240MariaDB 12.2.2bMySQL 9.6.0bOracle DB 23.26.1abPostgreSQL 18SQL Server 2025bSQLite 3.51.0From clause table namesFrom clause column namesWith clause column names
  1. Some variants
  2. Some variants

Deviations

Some systems allow omitting a table name where the standard requires one.

BigQuery 2026-02-18Db2 (LUW) 12.1.3DuckDB 1.4.0H2 2.4.240MariaDB 12.2.2MySQL 9.6.0Oracle DB 23.26.1PostgreSQL 18SQL Server 2025SQLite 3.51.0Required for: (SELECT …) [AS] tRequired for: (VALUES …) [AS] tRequired for: JSON_TABLE(…) [AS] tEnforces correct number [AS] t()Enforces unique names [AS] t()
Related Features

You can’t catch up on 20 years of SQL evolution in one day. Subscribe the newsletter via E-Mail, Bluesky or RSS to gradually catch up and to keep modern-⁠sql.com on your radar.

About the Author

Photo of Markus Winand

Markus Winand provides insights into SQL and shows how different systems support it at modern-sql.com. Previously he made use-the-index-luke.com, which is still actively maintained. Markus can be hired as trainer, speaker and consultant via winand.at.

Buy the Book

Cover of “SQL Performance Explained”: Squirrel running on grass

The essence of SQL tuning in 200 pages

Buy now!
(paperback and/or PDF)

Paperback also available at Amazon.com.

Hire Markus

Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »

Connect with Markus Winand

Subscribe mailinglistsSubscribe the RSS feedMarkus Winand on LinkedInMarkus Winand on XINGMarkus Winand on MastodonMarkus Winand on Bluesky
Copyright 2015-2026 Markus Winand. All righs reserved.
Legal | Contact | NO WARRANTY | Trademarks | Privacy and GDPR