How do I add a Primary in Hive version 0.14.0.2.0.0-2041?

Asked

Viewed 55 times

0

How to add a Primary in Hive version 0.14.0.2.0.0-2041   ?

Trying

CREATE TABLE simple_rule (
  simple_rule_id           int(10) unsigned default '0' not null auto_increment,
  condition_analysis_id    int(10) unsigned NOT NULL,
  goal_analysis_id         int(10) unsigned NOT NULL,

  PRIMARY KEY (simple_rule_id),
  UNIQUE (condition_analysis_id, goal_analysis_id)
);

1 answer

0

Hive is not a relational bank and there is not the same concept of primary/foreign key.

But you can add this information in the Table Metadata:

CREATE TABLE simple_rule (
    simple_rule_id          int 
    condition_analysis_id   int,
    goal_analysis_id        int,
)
TBLPROPERTIES("PRIMARY KEY"="simple_rule_id");

But I reinforce that this won’t make any difference on the table.

  • Thank you, as I get a field with unique records , in case of repeating the same load ?

  • The Hive is constantly evolving, as the version may exist PRIMARY KEY. The "Hive SQL" language (sometimes abbreviated HQL) is an abstraction (no matter the fact that it is implementing after Mapreduce), and as such, is oriented to the relational model, and as far as possible compatible with SQL (old) ISO standards.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.