hql statement hive database operations - Wukong wisdom Education

Display database information

hive> desc database db_hive;

OK

db_hive     hdfs://master:9000/user/hive/warehouse/db_hive.db    hadoopUSER       

Display database details, extended

hive> desc database extended db_hive;

OK

db_hive     hdfs://master:9000/user/hive/warehouse/db_hive.db    hadoopUSER  

Switching current database

hive (default)> use db_hive;

 Switching current database

hive (default)> use db_hive;

Modify the database

Users can use the ALTER DATABASE command to set the key DBPROPERTIES a database - the value of an attribute value, attribute information described in this database. Other metadata information database is unalterable, including the name and location of the database directory database is located.

hive (default)> alter database db_hive set dbproperties('createtime'='20170830');

View the results in the modification of the hive

hive> desc database extended db_hive;

db_name comment location        owner_name      owner_type      parameters

db_hive         hdfs://master:8020/user/hive/warehouse/db_hive.db    hadoop USER    {createtime=20170830}

Delete Database

1. Delete empty database

hive>drop database db_hive2;

2. If you delete the database does not exist, the best use of the database to determine whether there is if exists

hive> drop database db_hive;

FAILED: SemanticException [Error 10072]: Database does not exist: db_hive

hive> drop database if exists db_hive2;

3. If the database is not empty, you can use cascade command, forced to delete

hive> drop database db_hive;

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

hive> drop database db_hive cascade;

The above article content from "Monkey Wisdom Education": www.wukongone.com, "Wukong wisdom education" is a professional video teaching large data network, exclusive tailor your future.

Guess you like

Origin www.cnblogs.com/wukongone/p/11955561.html