Change column datatypes in Hive database

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am new to Hive database. Can someone please help me to change the datatype in Hive database? Below is a complete information about the same.



I have a database named "test". It has a table "name". Below is a query I used while creating a column in name table.



create table name(custID String,nameValuePairs array<struct< key:String, value:String>>) row format delimited fields terminated by '/' collection items terminated by '|' map keys terminated by '=' lines terminated by 'n';


Now, I want to change the datatype entry of column name "nameValuePairs".



Currently the column nameValuePairs has datatype array<struct< key:String, value:String>>.



Now I want to change the datatype to array<struct< something:somedatatype, value:String>>.










share|improve this question























  • Since this seems to be a sql question, see also dba.stackexchange.com
    – Jeff Schaller
    Sep 9 '16 at 11:37














up vote
1
down vote

favorite












I am new to Hive database. Can someone please help me to change the datatype in Hive database? Below is a complete information about the same.



I have a database named "test". It has a table "name". Below is a query I used while creating a column in name table.



create table name(custID String,nameValuePairs array<struct< key:String, value:String>>) row format delimited fields terminated by '/' collection items terminated by '|' map keys terminated by '=' lines terminated by 'n';


Now, I want to change the datatype entry of column name "nameValuePairs".



Currently the column nameValuePairs has datatype array<struct< key:String, value:String>>.



Now I want to change the datatype to array<struct< something:somedatatype, value:String>>.










share|improve this question























  • Since this seems to be a sql question, see also dba.stackexchange.com
    – Jeff Schaller
    Sep 9 '16 at 11:37












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am new to Hive database. Can someone please help me to change the datatype in Hive database? Below is a complete information about the same.



I have a database named "test". It has a table "name". Below is a query I used while creating a column in name table.



create table name(custID String,nameValuePairs array<struct< key:String, value:String>>) row format delimited fields terminated by '/' collection items terminated by '|' map keys terminated by '=' lines terminated by 'n';


Now, I want to change the datatype entry of column name "nameValuePairs".



Currently the column nameValuePairs has datatype array<struct< key:String, value:String>>.



Now I want to change the datatype to array<struct< something:somedatatype, value:String>>.










share|improve this question















I am new to Hive database. Can someone please help me to change the datatype in Hive database? Below is a complete information about the same.



I have a database named "test". It has a table "name". Below is a query I used while creating a column in name table.



create table name(custID String,nameValuePairs array<struct< key:String, value:String>>) row format delimited fields terminated by '/' collection items terminated by '|' map keys terminated by '=' lines terminated by 'n';


Now, I want to change the datatype entry of column name "nameValuePairs".



Currently the column nameValuePairs has datatype array<struct< key:String, value:String>>.



Now I want to change the datatype to array<struct< something:somedatatype, value:String>>.







database sql hadoop apache-hive






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 28 '16 at 21:05









Tomasz

8,11752560




8,11752560










asked Sep 9 '16 at 8:43









Nitesh B.

3711417




3711417











  • Since this seems to be a sql question, see also dba.stackexchange.com
    – Jeff Schaller
    Sep 9 '16 at 11:37
















  • Since this seems to be a sql question, see also dba.stackexchange.com
    – Jeff Schaller
    Sep 9 '16 at 11:37















Since this seems to be a sql question, see also dba.stackexchange.com
– Jeff Schaller
Sep 9 '16 at 11:37




Since this seems to be a sql question, see also dba.stackexchange.com
– Jeff Schaller
Sep 9 '16 at 11:37










1 Answer
1






active

oldest

votes

















up vote
0
down vote













You need to use the following ALTER TABLE syntax:



ALTER TABLE table_name CHANGE column_name column_name newType


To break it down, you are:



  • Making a change to the table: ALTER TABLE

  • Defining what table you are changing: table_name

  • Defining what column you will change: CHANGE column_name

  • Defining the change (you can also change column_name hence the double mention): column_name newType

Hope this helps.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f308822%2fchange-column-datatypes-in-hive-database%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    You need to use the following ALTER TABLE syntax:



    ALTER TABLE table_name CHANGE column_name column_name newType


    To break it down, you are:



    • Making a change to the table: ALTER TABLE

    • Defining what table you are changing: table_name

    • Defining what column you will change: CHANGE column_name

    • Defining the change (you can also change column_name hence the double mention): column_name newType

    Hope this helps.






    share|improve this answer
























      up vote
      0
      down vote













      You need to use the following ALTER TABLE syntax:



      ALTER TABLE table_name CHANGE column_name column_name newType


      To break it down, you are:



      • Making a change to the table: ALTER TABLE

      • Defining what table you are changing: table_name

      • Defining what column you will change: CHANGE column_name

      • Defining the change (you can also change column_name hence the double mention): column_name newType

      Hope this helps.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        You need to use the following ALTER TABLE syntax:



        ALTER TABLE table_name CHANGE column_name column_name newType


        To break it down, you are:



        • Making a change to the table: ALTER TABLE

        • Defining what table you are changing: table_name

        • Defining what column you will change: CHANGE column_name

        • Defining the change (you can also change column_name hence the double mention): column_name newType

        Hope this helps.






        share|improve this answer












        You need to use the following ALTER TABLE syntax:



        ALTER TABLE table_name CHANGE column_name column_name newType


        To break it down, you are:



        • Making a change to the table: ALTER TABLE

        • Defining what table you are changing: table_name

        • Defining what column you will change: CHANGE column_name

        • Defining the change (you can also change column_name hence the double mention): column_name newType

        Hope this helps.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 9 '16 at 8:51









        I_GNU_it_all_along

        1,099418




        1,099418



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f308822%2fchange-column-datatypes-in-hive-database%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)