100% found this document useful (1 vote)
92 views

Comandos Hive SQL

This document discusses Hive commands and includes the following categories: 1. DDL commands for defining metadata like CREATE TABLE, CREATE DATABASE, ALTER TABLE, and CREATE/DROP VIEW. 2. DML commands for manipulating data like LOAD, INSERT, UPDATE, DELETE, and MERGE. 3. SELECT commands for querying data with clauses like WHERE, GROUP BY, HAVING, JOIN, mathematical and string functions.

Uploaded by

Christiam Niño
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
92 views

Comandos Hive SQL

This document discusses Hive commands and includes the following categories: 1. DDL commands for defining metadata like CREATE TABLE, CREATE DATABASE, ALTER TABLE, and CREATE/DROP VIEW. 2. DML commands for manipulating data like LOAD, INSERT, UPDATE, DELETE, and MERGE. 3. SELECT commands for querying data with clauses like WHERE, GROUP BY, HAVING, JOIN, mathematical and string functions.

Uploaded by

Christiam Niño
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Hive.

Comandos
Hive
Comandos DDL (DATA DEFINITION LANGUAGE)
❑CREATE TABLE
❑Create/Drop/Alter/Use Database create table table_name (
id int,
❑Create/Drop/Truncate Table dtDontQuery string,
❑Alter Table/Partition/Column name string
)
❑Create/Drop/Alter View partitioned by (date string)
❑Create/Drop/Alter Index
Create database db1
❑Create/Drop Macro
❑……
Hive
Comandos DML (DATA MANIPULATION LANGUAGE)
❑LOAD LOAD DATA LOCAL INPATH '/home/curso/Escritorio/employee.txt'
OVERWRITE INTO TABLE employee_internal;
❑INSERT
❑UPDATE INSERT INTO TABLE students
❑DELETE VALUES ('fred flintstone', 35, 1.28), ('barney rubble', 32, 2.32);
❑MERGE
DELETE FROM students WHERE gpa <= 1,0;

merge into customer


using ( select * from new_customer_stage) sub
on sub.id = customer.id
when matched then update set name = sub.name, state =
sub.new_state
when not matched then insert values (sub.id, sub.name,
sub.state);
Hive
Comandos SELECT
SELECT [ALL | DISTINCT] select_expr, select_expr, ...
FROM table_reference
[WHERE where_condition]
[GROUP BY col_list]
[HAVING having_condition]
[CLUSTER BY col_list | [DISTRIBUTE BY col_list] [SORT BY col_list]]
[LIMIT number]
;

Mathematical Functions
Collection Functions
Type Conversion Functions
Date Functions
Conditional Functions
String Functions
Misc Functions
Hive
Comandos SELECT
SELECT * FROM employee WHERE salary>30000;

SELECT Id, Name, Dept FROM employee ORDER BY DEPT;

SELECT Dept,count(*) FROM employee GROUP BY DEPT;

SELECT c.ID, c.NAME, c.AGE, o.AMOUNT FROM CUSTOMERS c JOIN ORDERS o


ON (c.ID = o.CUSTOMER_ID);

SELECT c.ID, c.NAME, o.AMOUNT, o.DATE FROM CUSTOMERS c


LEFT OUTER JOIN ORDERS o
ON (c.ID = o.CUSTOMER_ID);

You might also like