You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by 皮皮 <wa...@qq.com> on 2011/05/26 07:40:43 UTC

回复: 回复: How to create table like other databases' table?

I can't do  it using hive 0.6. may be hive didn't support  it in 0.6.


------------------

 
 
------------------ 原始邮件 ------------------
发件人: "������"<wa...@gmail.com>;
发送时间: 2011年5月26日(星期四) 中午1:16
收件人: "user"<us...@hive.apache.org>; 

主题: Re: 回复: How to create table like other databases' table?

 
 Hive does support a cross-database query.

For e.g.,


hive> create database test;
OK
Time taken: 0.456 seconds
hive> use test;
OK
 Time taken: 0.065 seconds
hive> create table test1 (a string);
OK
Time taken: 0.145 seconds
hive> use default;
OK
Time taken: 0.059 seconds
 hive> create table test2 like test.test1;
OK
Time taken: 0.162 seconds
hive> describe extended test2;
OK
a	string
 
...


Tested on Hive trunk.


HTH,


- Youngwoo


2011/5/26 皮皮 <wa...@qq.com>
 But a and b  are not in same database...
..


 
 ------------------ 原始邮件 ------------------
 发件人: "      "<wa...@gmail.com>;
发送时间: 2011年5月26日(星期四) 中午11:48
收件人: "user"<us...@hive.apache.org>; 
 
主题: Re: How to create table like other databases' table?


 
 Hi,

Hive supports 'CREATE TABLE ... LIKE ...' statement. so you can create a table like following:


CREATE TABLE test2 LIKE test1;


Syntax:
  CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name   LIKE existing_table_name   [LOCATION hdfs_path]For more details, See http://wiki.apache.org/hadoop/Hive/LanguageManual/DDL


 Regards,
 

- Youngwoo



2011/5/26 皮皮 <wa...@qq.com>
 Hi ,all. 
    How to create table like other database's  table ? e.g. i create table a in test1 , and then I want create table b in test2, that  have a  same  shema  with table a in test1.
    Thanks.