We can rename the name of a table or field with SQL, which is the alias of the table or field.
Aliases are created to make table or column names more readable.
Used in SQL AS To create an alias. Alias syntax for the table: Alias syntax for the column: Create Create 5.32.1. Grammar ¶
SELECT column1, column2....
FROM table_name AS alias_name
WHERE [condition];
SELECT column_name AS alias_name
FROM table_name
WHERE [condition];
5.32.2. Example ¶
COMPANY
表( 下载 COMPANY SQL 文件 ), the data are as follows:runoobdb# select * from COMPANY;
id | name | age | address | salary
----+-------+-----+-----------+--------
1 | Paul | 32 | California| 20000
2 | Allen | 25 | Texas | 15000
3 | Teddy | 23 | Norway | 20000
4 | Mark | 25 | Rich-Mond | 65000
5 | David | 27 | Texas | 85000
6 | Kim | 22 | South-Hall| 45000
7 | James | 24 | Houston | 10000
(7 rows)
DEPARTMENT
表( 下载 COMPANY SQL 文件 ), the data are as follows:runoobdb=# SELECT * from DEPARTMENT;
id | dept | emp_id
----+-------------+--------
1 | IT Billing | 1
2 | Engineering | 2
3 | Finance | 7
4 | Engineering | 3
5 | Finance | 4
6 | Engineering | 5
7 | Finance | 6
(7 rows)