日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

hive数据库定义

發布時間:2025/3/11 数据库 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hive数据库定义 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


默認數據庫"default"

可以顯式切換數據庫:hive> use 數據庫名;


創建

hive>CREATE DATABASE ?
[IF NOT EXISTS] mydb ?
[LOCATION] '/.......' ?
[COMMENT] '....';

實例

hive (default)> create database test_db comment 'test database';
OK
Time taken: 0.33 seconds

hive (default)> create database if not exists test_db comment 'test database';
OK
Time taken: 0.013 seconds

hive (default)> create database if not exists test2_dblocation'/home/hive2.1/test_database';
OK
Time taken: 0.054 seconds

注意:location 不是linux的文件系統,是hdfs的。location是指定目錄,

如果不指定會默認放到/user/hive/warehouse 下。下面查看可知。


hive (test2_db)> describe database test2_db;
OK
db_name comment location ? ? ? ?owner_name ? ? ?owner_type ? ? ?parameters
test2_db ? ? ? ? ? ? ? ?hdfs://hello110:9000/home/hive2.1/test_database hadoop ?USER

Linux文件系統里沒有
[hadoop@hello110 test_database]$ pwd
/home/hive2.1/test_database
[hadoop@hello110 test_database]$ ll
total 0


顯示

hive>SHOW DATABASES;

描述

hive>DESCRIBE DATABASE [extended] mydb;

刪除

hive>DROP DATABASE [IF EXISTS] mydb [CASCADE];

實例

hive (test2_db)> drop database test2_db;
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. InvalidOperationException(message:Database test2_db is not empty. One or more tables exist.)


cascade關鍵字,強制刪除,hive會把文件移動hdfs回收站

hive (test2_db)> drop database test2_db cascade;
Moved: 'hdfs://hello110:9000/home/hive2.1/test_database/t1' to trash at: hdfs://hello110:9000/user/hadoop/.Trash/Current
Moved: 'hdfs://hello110:9000/home/hive2.1/test_database' to trash at: hdfs://hello110:9000/user/hadoop/.Trash/Current
OK
Time taken: 1.384 seconds
hive (test2_db)>?



總結

以上是生活随笔為你收集整理的hive数据库定义的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。