使用表的别名-SQL语言基础

时间:2021-04-25 19:38:17
【文件属性】:
文件名称:使用表的别名-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2021-04-25 19:38:17
SQL 基础 使用表的别名 * SQL> SELECT emp.empno, emp.ename, emp.deptno, 2 dept.deptno, dept.loc 3 FROM emp, dept 4 WHERE emp.deptno=dept.deptno; SQL> SELECT e.empno, e.ename, e.deptno, 2 d.deptno, d.loc 3 FROM emp e, dept d 4 WHERE e.deptno= d.deptno; 使用的表的别名来简化查询 * SELECT emp.empno, emp.ename, emp.deptno, dept.deptno, dept.loc FROM emp, dept WHERE emp.deptno=dept.deptno; Table Aliases Qualifying column names with table names can be very time consuming, particularly if table names are lengthy. You can use table aliases instead of table names. Just as a column alias gives a column another name, a table alias gives a table another name. Table aliases help to keep SQL code smaller, therefore using less memory. Notice how table aliases are identified in the FROM clause in the example. The table name is specified in full, followed by a space and then the table alias. The EMP table has been given an alias of E, whereas the DEPT table has an alias of D. Guidelines Table aliases can be up to 30 characters in length, but the shorter they are the better. If a table alias is used for a particular table name in the FROM clause, then that table alias must be substituted for the table name throughout the SELECT statement. Table aliases should be meaningful. The table alias is valid only for the current SELECT statement. Instructor Note Explain that it is always recommended to use meaningful alias names.

网友评论