as 一般用在两个地方,一个是query的时候,用来重新指定返回的column 名字 如:一个table 有个column叫 id, 我们的query是 select id from table1. 但是如果你不想叫id了,就可以重新命名,如叫 systemID 就可以这样写 select id as systemId from table1; 还有一个用法就是在create table 或 procedure 的时候,as 是个关键字。 例如 create table test as select * from table1 这时候就会create 一个table test,他是完全copy table table1里的全部数据。 create procdure name as (is) begin end; 具体可以参考 如何建立procedure。 这个时候 as 和is可以互换。
例外还有就是它的作用:
1)用别名可以简化表名,在表名长的时候可以明显让代码简明了解 如:select s.sno, c.cno from student s, course c, sc where s.sno = sc.sno and c.cno = sc.cno 2)多表的时候,用别名可以明显的区别表之间,让代码清晰明了。 select t1.*, t2.* from tab t1, tab t2 where t1.xx = t2.xx...