hive
2023-03-29 22:20:31 4 举报
AI智能生成
hive基础
作者其他创作
大纲/内容
DDL数据定义
创建数据库<br>
create database DBname;
对表的一些操作
数据类型
<ul><li><span style="font-size: inherit;">集合数据类型Data_Type</span></li><li><span style="font-size: inherit;">primitive_type</span></li><li><span style="font-size: inherit;">Array<data_type></span></li><li><span style="font-size: inherit;">Map<primitive_type,data_type></span></li><li><span style="font-size: inherit;">Struct<col_name:data_type> [comment col_comment]<br>普通数据类型</span></li><li>TINYINT</li><li>Smallint</li><li>Int</li><li>Bigint</li><li>Boolean</li><li>Float</li><li>Double</li><li>String</li><li>Binary</li><li>Timestamp</li><li>Decimal</li><li>Date</li><li>Varchar</li><li>Char</li></ul>
建表的三种语句
create table tbname(col type [comment "col_comment"])<br>[COMMENT 'This is an external table']<br>[ROW FORMAT DELIMITED ]<br>[FIELDS TERMINATED BY '|' ] //如何分隔列(字段)<br>[collection items terminated by "," ] //指定用什么分隔集合<br>[MAP KEYS TERMINATED BY ':' ] //指定用什么分隔map映射<br>[LOCATION '/user/employee'; ] // 数据存储路径(HDFS)<br>
create table tbname1 like tbname; <font color="#ec7270">//复制表结构</font><br>
<font color="#ec7270">//把一张表的某些字段抽取出来,创建成一张新表,使用as</font><br>create table tbname as tbname
内部表/外部表
内部表:删除表时,元数据与数据都会被删除
外部表:删除表只删除metastore的元数据,不删除表数据
hive数据仓库配置属性
set hive.cli.print.current.db=true;提示显示当前数据库
查询
show databases like '*site'; 筛选查找库<br>desc database db_name 查看数据仓库详细信息<br>desc database extended db_name 查看数据仓库详细信息<br>show tables 查看库下的表<br>desc 查看表结构<br>desc extended table_name //查看更多扩展信息<br>desc formatted table_name <br>select *from table_name 查看数据表数据<br>
收藏
0 条评论
下一页