-
Notifications
You must be signed in to change notification settings - Fork 14
/
HiveDatabase.md
56 lines (49 loc) · 1.34 KB
/
HiveDatabase.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Hive Database
## Create Database
### Create Database Statement
```
Syntax: CREATE DATABASE|SCHEMA [IF NOT EXISTS] <database name>
hive> CREATE DATABASE [IF NOT EXISTS] userdb;
# or
hive> CREATE SCHEMA userdb;
```
```
hive> SHOW DATABASES;
default
userdb
```
### JDBC Program
- `HiveCreateDb`
### Tips
```
hiveserver2 &
netstat -anp |grep 10000
tail -f -n 99 /tmp/hadoop/hive.log
```
[HiveServer2](http://tc210:10002/)
`vi /usr/local/hadoop/etc/hadoop/core-site.xml`
```
<property>
<name>hadoop.proxyuser.hadoop.groups</name>
<value>hadoop</value>
<description>Allow the superuser oozie to impersonate any members of the group group1 and group2</description>
</property>
<property>
<name>hadoop.proxyuser.hadoop.hosts</name>
<value>tc210,127.0.0.1,localhost</value>
<description>The superuser can connect only from host1 and host2 to impersonate a user</description>
</property>
```
## Drop Database
### Drop Database Statement
```
DROP DATABASE StatementDROP (DATABASE|SCHEMA) [IF EXISTS] database_name [RESTRICT|CASCADE];
hive> DROP DATABASE IF EXISTS userdb;
hive> DROP DATABASE IF EXISTS userdb CASCADE;
hive> DROP SCHEMA userdb;
```
### JDBC Program
- `HiveDropDb`
## References
- [Hive - Create Database](https://www.tutorialspoint.com/hive/hive_create_database.htm)
- [Hive - Drop Database](https://www.tutorialspoint.com/hive/hive_drop_database.htm)