🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to PostgreSQL Notes
Topic #29

PostgreSQL AS


Aliases

SQL aliases are used to give a table, or a column in a table, a temporary name.

Aliases are often used to make column names more readable.

An alias only exists for the duration of that query.

An alias is created with the AS keyword.

Example

SELECT customer_id AS id
FROM customers;

AS is Optional

Actually, you can skip the AS keyword and get the same result:

Example

SELECT customer_id id
FROM customers;

Concatenate Columns

The AS keyword is often used when two or more fields are concatenated into one.

To concatenate two fields use ||.

Example

SELECT product_name
|| unit AS product
FROM products;

Note: In the result of the example above we are missing a space between product_name and unit. To add a space when concatenating, use || ' ' ||.

Example

SELECT product_name || ' ' || unit AS product
FROM products;

Using Aliases With a Space Character

If you want your alias to contain one or more spaces, like "My Great Products", surround your alias with double quotes.

Example

SELECT product_name AS "My Great Products"
FROM products;

Want to go beyond the notes?

Join CodingNow 2.0's PostgreSQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

PostgreSQL AS – FAQs

Quick answers about learning PostgreSQL AS in PostgreSQL.

This free note from CodingNow 2.0 explains PostgreSQL AS in PostgreSQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every PostgreSQL topic on CodingNow 2.0, including PostgreSQL AS, is 100% free with no signup required.
With focused practice, most students grasp PostgreSQL AS in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now