咱們對別名的認識最初是在數據庫中,例如:數據庫之select時取別名的作法是這樣的:html
select 列名 as 列別名,//方法1 列名 列別名,//方法2 from 表名;
這兩種取別名方法是全部數據庫通用的。在 SQL 語句中,能夠爲表名稱及字段(列)名稱指定別名(Alias),別名是 SQL 標準語法,幾乎全部的數據庫系統都支持。linux
除了數據庫之外,在任何有計算機的地方均可以用別名來代替一些東西,程序員能夠減小不少的工做量,例如linux能夠爲命令設置別名,再如mybatis能夠爲類型設置別名。程序員
在mybatis-config.xml配置別名以下:數據庫
<typeAliases> <package name="cn.mybatis.core.bean"/> </typeAliases>
它的做用是讓Mapper.xml中的參數找到對應類,以下面parameterType="person",若是沒有配置別名,則要改成parameterType="cn.mybatis.core.bean.Person",配置別名首先固然要保證對象實體的存在,這樣配置別名後,均可找到對應的參數;mybatis
<mapper namespace="cn.mybatis.core.dao.PersonDao"> <insert id="insertPerson" parameterType="person"> insert into t_person(id,name,birthday) values (#{id},#{name},#{birthday}) </insert> </mapper>