企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
内部表又称为管理表。 <br/> **内部表的特点:** <mark>1. 在hive中删除了内部表,存储在HDFS上的数据和该表存储在mysql中对应的元数据一同被删除。</mark> <mark>2. 对内部表的任何更改都会对存储在hdfs上的数据和存储在mysql中的元数据产生影响。 <br/> **创建 empt内部表** ```sql create table if not exists empt( empt_id int comment "empt ID", empt_name string comment "empt name" ) comment "empt table" stored as textfile -- /home/hadoop/hive/warehouse/hivebook.db/要求已存在,empt为表名 location "/home/hadoop/hive/warehouse/hivebook.db/empt" ; ``` **查看建表信息** ```shell 0: jdbc:hive2://hadoop101:10000> show create table empt; +----------------------------------------------------+--+ | createtab_stmt | +----------------------------------------------------+--+ | CREATE TABLE `empt`( | | `empt_id` int COMMENT 'empt ID', | | `empt_name` string COMMENT 'empt name') | | COMMENT 'empt table' | | ROW FORMAT SERDE | | 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' | | STORED AS INPUTFORMAT | | 'org.apache.hadoop.mapred.TextInputFormat' | | OUTPUTFORMAT | | 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' | | LOCATION | | 'hdfs://hadoop101:9000/home/hadoop/hive/warehouse/hivebook.db/empt' | | TBLPROPERTIES ( | | 'transient_lastDdlTime'='1607494285') | +----------------------------------------------------+--+ ``` **查看表类型** ``` 0: jdbc:hive2://hadoop101:10000> desc formatted empt; +-------------------------------+----------------------------------------------------+-----------------------+--+ | col_name | data_type | comment | +-------------------------------+----------------------------------------------------+-----------------------+--+ | # col_name | data_type | comment | | | NULL | NULL | | empt_id | int | empt ID | | empt_name | string | empt name | | | NULL | NULL | | # Detailed Table Information | NULL | NULL | | Database: | hivebook | NULL | | Owner: | root | NULL | | CreateTime: | Wed Dec 09 14:11:25 CST 2020 | NULL | | LastAccessTime: | UNKNOWN | NULL | | Protect Mode: | None | NULL | | Retention: | 0 | NULL | | Location: | hdfs://hadoop101:9000/home/hadoop/hive/warehouse/hivebook.db/empt | NULL | | Table Type: | MANAGED_TABLE | NULL | | Table Parameters: | NULL | NULL | | | comment | empt table | | | transient_lastDdlTime | 1607494285 | | | NULL | NULL | | # Storage Information | NULL | NULL | | SerDe Library: | org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | NULL | | InputFormat: | org.apache.hadoop.mapred.TextInputFormat | NULL | | OutputFormat: | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | NULL | | Compressed: | No | NULL | | Num Buckets: | -1 | NULL | | Bucket Columns: | [] | NULL | | Sort Columns: | [] | NULL | | Storage Desc Params: | NULL | NULL | | | serialization.format | 1 | +-------------------------------+----------------------------------------------------+-----------------------+--+ ```