All Products
Search
Document Center

E-MapReduce:Operasi Hive dasar

Last Updated:Mar 27, 2026

Panduan ini menjelaskan cara menggunakan Hive CLI pada kluster E-MapReduce (EMR) untuk membuat dan mengelola database serta tabel, serta menjalankan pernyataan SQL guna memasukkan dan mengkueri data.

Prasyarat

Sebelum memulai, pastikan Anda telah:

  • Membuat kluster EMR dengan layanan Hive yang diaktifkan. Untuk informasi lebih lanjut, lihat Create a cluster.

Buka Hive CLI

  1. Login ke kluster EMR melalui SSH. Lihat Log on to a cluster.

  2. Beralih ke pengguna hadoop:

    su hadoop
  3. Jalankan Hive CLI:

    hive

Kelola database

Contoh berikut menggunakan database bernama testdb.

OperasiPerintahIndikator keberhasilan
Buatcreate database if not exists testdb;Output berisi OK
Lihat detaildesc database testdb;
Beralih ke databaseuse testdb;
Hapusdrop database if exists testdb;Output berisi OK

Buat database

create database if not exists testdb;

Jika output berisi OK, database berhasil dibuat.

Lihat detail database

desc database testdb;

Beralih ke database

use testdb;

Hapus database

drop database if exists testdb;

Jika output berisi OK, database berhasil dihapus.

Kelola tabel

Contoh berikut menggunakan tabel bernama t dengan dua kolom: id (bigint) dan value (string).

OperasiPerintahIndikator keberhasilan
Buatcreate table if not exists t (id bigint, value string);Output berisi OK
Lihat detaildesc formatted t;
Daftar semua tabelshow tables;Mengembalikan OK lalu t
Hapusdrop table if exists t;Output berisi OK

Buat tabel

create table if not exists t (id bigint, value string);

Jika output berisi OK, tabel berhasil dibuat.

Lihat detail tabel

desc formatted t;

Daftar semua tabel

show tables;

Output yang diharapkan:

OK
t

Hapus tabel

drop table if exists t;

Jika output berisi OK, tabel berhasil dihapus.

Jalankan pernyataan SQL

Contoh berikut memasukkan satu baris ke dalam t lalu mengkuerinya.

Masukkan baris

insert into table t select 1, 'value-1';

Output yang diharapkan:

OK
Time taken: 14.73 seconds

Baris kueri

select * from t limit 10;

Output yang diharapkan:

OK
1       value-1
Time taken: 11.48 seconds, Fetched: 1 row(s)

data agregat

select value, count(id) from t group by value;

Output yang diharapkan:

OK
value-1 1
Time taken: 20.11 seconds, Fetched: 1 row(s)