1、进入装有 inceptorservice 角色的节点transwarp –t –h localhost,如果当前节点不是inceptor节点,则可以把localhost换为inceptor节点的ip,在inceptor中的语句不区分大小写。
2、查看可用database:showdatabases;
3、系统默认database为default;
4、根据实际情况进去要操作的database:use databasename(当前测试建立的仓库);
5、查看仓库中可用表:showtables;
6、创建基于hdfs数据的inceptor外表如下
drop table if test1;
create external table if not exists test1(yfbm string,rqbm string,ZSXXDZ string,jtfs string,wfxwstring,byl string) row format delimited fields terminated by ',' location'/ceshi/tt';
(droptable if exists test1表示如果inceptor的databasename仓库里有test1这张表则会删除此表,在执行建外表语句时若确定inceptor内无此表则可以不用执行此语句,test1表示需要新建的表名,慎用。)
(create external table if not exists [表名] (【字段名】 【字段属性】,【字段名】 【字段属性】…) row format delimited fields terminated by '[分隔符]'location '[hdfs上目录] ';此语句是基于HDFS数据创建inceptor外表语句,字段属性默认成string即可,不建议使用varchar(128)、char(2)等字段属性,分隔符是执行完hdfs dfs –tail –f /ceshi/tt/part-m-00000命令时所看到的文件中各字段之间的分割符号比如逗号、空格等)
7、查询新建的inceptor外表,看是否成功创建:
Select* from test1 limit 10;