DatabasesinHive1. if no database is defined in hive, this "default" is used as the default database. 2. the syntax for creating a database is simple: hivecreatedatabasefinancials; if there is a stored ALS, an error will be thrown, which can be like this: hivecreatedatabasesIFNOTEXISTSfi
Databases in Hive 1. If no database is defined in hive, this "default" is used as the default database. 2. the syntax for creating a database is simple: hive create databasedocumals; IF there is a database, an error will be thrown. You can do this: hive create databases if not exists fi.
Zookeeper
Databases in Hive
1. If the database is not defined in hive, the "default" is used as the default database.
2. the syntax for creating a database is simple:
Hive> create databasedocumals;
If the exist als statement exists, an error will be thrown. You can do this:
Hive> create databases if not exists exist als;
3. In the "database" command line, you can use "schema" instead of "database ".
4. If there are many databases, you can use related expressions, letters starting with like or alike + Database Name and ending with ". *", such:
Hive> show databases like 'F. * '; (f indicates a financial database)
5. hive creates a path for each database, and the table is stored in the corresponding sub-path. The default "default" database does not have its own path. In this attribute, hive. metastore. warehouse. dir is set. The default attribute value is/user/hive/warehouse.
When the database financial is created, hive will create the path/user/hive/warehouse and financial. db for it, And. db is an extension of the database name.
N you can also modify the default path:
Hive> create database privileges als
> Location '/my/preferred/directory ';
N can add explanatory content to the database:
Hive> create database privileges als
> Comment 'holds all financial tables ';
The n describe database command also indicates the database path.
N combines the key-values attribute with the database, for example:
Hive> create database privileges als
> With dbproperties ('creator = 'markmoney', 'data' = '2017-10-18 ');
The database information is described as follows:
Hive> describe database extendedals;
The n "use" command is used to make a database in the currently used database:
Hive> use external als;
Unfortunately, no command is used to show the currently used database. Therefore, we use the 'use' command to set the database as the currently used database. Because there is no database concept in hive.
6. Set the attributes to print out the current database:
Hive> set hive. cli. print. current. db = true;
Hive (events)> use default;
Hive (default)> sethive. cli. print. current. db = false;
Hive> .....
Delete A database: hive> drop database ifexists databases;
By default, hive does not allow you to delete databases that contain tables. First, you can delete the table and then use the 'cascade 'keyword on the command line. You can also use 'restrict ':
Hive> drop database if exists exist als cascade;
When a database is deleted, its path is also deleted.
7. You can set the key-Value Pair attribute in 'dbproperties.
Hive> alter database privileges als set dbproperties ('edited-by' = 'Joe dba ');