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 2025-09-02Db2 (LUW) 12.1.2MariaDB 12.0.2aMySQL 9.4.0bOracle DB 23.9cPostgreSQL 17SQL Server 2022adSQLite 3.50.0accepts as prior to table aliasfrom clause column nameswith clause (non-recursive)
  1. Only for values and select: FROM (VALUES | SELECT …) t(c1, c2)
  2. Only for select: FROM (SELECT …) t(c1, c2)
  3. Only for values, but then required: FROM (VALUES …) t(c1, c2)
  4. Only allowed at the very begin of a statement. E.g. with...insert...select

Extensions

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

Some systems allow renaming fewer columns as the table has so that only the first few columns are renamed.

BigQuery 2025-09-02Db2 (LUW) 12.1.2MariaDB 12.0.2MySQL 9.4.0Oracle DB 23.9PostgreSQL 17SQL Server 2022SQLite 3.50.0optional for: (select …)optional for: (values …)optional for: json_table(…)Fewer columns
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 TwitterMarkus Winand on Bluesky
Copyright 2015-2025 Markus Winand. All righs reserved.
Legal | Contact | NO WARRANTY | Trademarks | Privacy and GDPR