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 04:20:40 UTC

How to create table like other databases' table?

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.

Re: How to create table like other databases' table?

Posted by 김영우 <wa...@gmail.com>.
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

<http://wiki.apache.org/hadoop/Hive/LanguageManual/DDL>
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.
>
>
>