DEV Community

tongxi
tongxi

Posted on • Edited on

openGauss Aliases

SQL can rename a table or a column. The name is the alias of the table or the column. Aliases are created to improve the readability of table names or column names. In SQL, AS is used to create an alias.

Syntax

Column alias syntax

SELECT
{ * | [column [ AS ] output_name, ...] }
[ FROM from_item [, ...] ]
[ WHERE condition ];

Table alias syntax

SELECT column1, column2....
FROM table_name AS output_name
WHERE [condition];

Parameter Description

output_name

You may use the AS output_name clause to give an alias for an output column. The alias is used for displaying the output column. The name, value, and type keywords can be used as column aliases.

Examples

Use C to indicate the alias of the customer_t1 table to query data in the table.

openGauss=# SELECT c.c_first_name,c.amount FROM customer_t1 AS c;
c_first_name | amount
--------------+--------
Grace | 1000
Grace |
|
Joes | 2200
James | 5000
Local | 3000
Lily | 1000
Lily | 2000
(8 rows)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay