Renaming

We wish to rename columns of a table using the AS expression.

In this example, we wish to change the names of two columns from col_a and col_b to col_1 and col_2 respectively.

SELECT col_a AS col_1,
       col_b AS col_2,
       col_c
FROM table_1;

Here is how this works:

  • We assign a new name to each column using AS command. We have to explicitly rename each column and select columns that we wish to keep the same.
SQL
I/O