You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by Batyrshin Alexander <0x...@gmail.com> on 2017/01/16 08:28:27 UTC

How to recreate table?

 Hello,
I've recreated HBase table with data, but phoenix doesn't work on it. But i still see this table in phoenix.
How can I recreate pheonix table now?
As I know "drop table ... ; create table ..." in phoenix will destroy my HBase table with data.

Re: How to recreate table?

Posted by James Taylor <ja...@apache.org>.
Couple of other options:
1) connect with a CURRENT_SCN [1] earlier than any timestamp for your data.
For example, if you know you created the table a month ago, then use an SCN
value of the epoch time for 1/1/2016. Then issue the DROP TABLE command
from that connection and no data will be removed.
2) when you map to existing HBase table, use CREATE VIEW instead of CREATE
TABLE. That way you can enter a DROP VIEW to remove the mapping without
affecting your data.

Thanks,
James


[1]
http://phoenix.apache.org/faq.html#Can_phoenix_work_on_tables_with_arbitrary_timestamp_as_flexible_as_HBase_API

On Mon, Jan 16, 2017 at 8:51 AM, Josh Elser <jo...@gmail.com> wrote:

> You could create a new table with the same schema and then flip the
> underlying table out.
>
> * Rename the existing table to "foo"
> * Create your table via Phoenix with correct schema and desired name
> * Delete underlying HBase table that Phoenix created
> * Rename "foo" to the desired name
>
> I _think_ that would work.
>
>
> Batyrshin Alexander wrote:
>
>>   Hello,
>> I've recreated HBase table with data, but phoenix doesn't work on it. But
>> i still see this table in phoenix.
>> How can I recreate pheonix table now?
>> As I know "drop table ... ; create table ..." in phoenix will destroy my
>> HBase table with data.
>>
>

Re: How to recreate table?

Posted by James Taylor <ja...@apache.org>.
Yes, the consequences could be bad as you're bypassing the API that drops a
table (which does more than just update the SYSTEM. CATALOG). Please see
the recommendations in the previous emails.

On Mon, Jan 16, 2017 at 10:45 PM Batyrshin Alexander <0x...@gmail.com>
wrote:

> I've discovered that i can simple delete schema
>
> Like this:
>
> delete from SYSTEM.CATALOG where "TABLE_NAME" = 'my_table_name';
>
> Is this action has any consequence?
>
>
>
> > On 16 Jan 2017, at 19:51, Josh Elser <jo...@gmail.com> wrote:
>
> >
>
> > You could create a new table with the same schema and then flip the
> underlying table out.
>
> >
>
> > * Rename the existing table to "foo"
>
> > * Create your table via Phoenix with correct schema and desired name
>
> > * Delete underlying HBase table that Phoenix created
>
> > * Rename "foo" to the desired name
>
> >
>
> > I _think_ that would work.
>
> >
>
> > Batyrshin Alexander wrote:
>
> >>  Hello,
>
> >> I've recreated HBase table with data, but phoenix doesn't work on it.
> But i still see this table in phoenix.
>
> >> How can I recreate pheonix table now?
>
> >> As I know "drop table ... ; create table ..." in phoenix will destroy
> my HBase table with data.
>
>
>
>

Re: How to recreate table?

Posted by Batyrshin Alexander <0x...@gmail.com>.
I've discovered that i can simple delete schema 
Like this:
delete from SYSTEM.CATALOG where "TABLE_NAME" = 'my_table_name';
Is this action has any consequence?

> On 16 Jan 2017, at 19:51, Josh Elser <jo...@gmail.com> wrote:
> 
> You could create a new table with the same schema and then flip the underlying table out.
> 
> * Rename the existing table to "foo"
> * Create your table via Phoenix with correct schema and desired name
> * Delete underlying HBase table that Phoenix created
> * Rename "foo" to the desired name
> 
> I _think_ that would work.
> 
> Batyrshin Alexander wrote:
>>  Hello,
>> I've recreated HBase table with data, but phoenix doesn't work on it. But i still see this table in phoenix.
>> How can I recreate pheonix table now?
>> As I know "drop table ... ; create table ..." in phoenix will destroy my HBase table with data.


Re: How to recreate table?

Posted by Josh Elser <jo...@gmail.com>.
You could create a new table with the same schema and then flip the 
underlying table out.

* Rename the existing table to "foo"
* Create your table via Phoenix with correct schema and desired name
* Delete underlying HBase table that Phoenix created
* Rename "foo" to the desired name

I _think_ that would work.

Batyrshin Alexander wrote:
>   Hello,
> I've recreated HBase table with data, but phoenix doesn't work on it. But i still see this table in phoenix.
> How can I recreate pheonix table now?
> As I know "drop table ... ; create table ..." in phoenix will destroy my HBase table with data.