How to increase column limit of a table in SQLite?












1















SQLite: How can we configure the maximum number of columns allowed in a table?










share|improve this question


















  • 3





    If you need more than 2000 columns this almost always indicates a bad database model (i.e. not normalized)

    – a_horse_with_no_name
    Nov 1 '18 at 11:47
















1















SQLite: How can we configure the maximum number of columns allowed in a table?










share|improve this question


















  • 3





    If you need more than 2000 columns this almost always indicates a bad database model (i.e. not normalized)

    – a_horse_with_no_name
    Nov 1 '18 at 11:47














1












1








1








SQLite: How can we configure the maximum number of columns allowed in a table?










share|improve this question














SQLite: How can we configure the maximum number of columns allowed in a table?







sqlite






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 1 '18 at 7:07









Vishnu CBVishnu CB

61




61








  • 3





    If you need more than 2000 columns this almost always indicates a bad database model (i.e. not normalized)

    – a_horse_with_no_name
    Nov 1 '18 at 11:47














  • 3





    If you need more than 2000 columns this almost always indicates a bad database model (i.e. not normalized)

    – a_horse_with_no_name
    Nov 1 '18 at 11:47








3




3





If you need more than 2000 columns this almost always indicates a bad database model (i.e. not normalized)

– a_horse_with_no_name
Nov 1 '18 at 11:47





If you need more than 2000 columns this almost always indicates a bad database model (i.e. not normalized)

– a_horse_with_no_name
Nov 1 '18 at 11:47










3 Answers
3






active

oldest

votes


















1














You would have to obtain the Source Code for SQLLite, change the value of SQLITE_MAX_COLUMN, recompile the code and distrbute the resulting executable.



However, more than 2000 columns in a single table sounds wrong to me.
Do you have lots of repeated fields in each row? That's poor Relational design.



If necessary, create a second table with the same primary key as the first and add your additional fields into that. You would have to issue two select statements to retrieve the values, though, because SQLITE_MAX_COLUMNS also applies to select statements, so you can't just join the two tables together.






share|improve this answer































    1














    As per SQLite documentation Limits In SQLite




    "Limits" in the context of sizes or quantities that can not be exceeded. We are concerned with things like the maximum number of bytes in a BLOB or the maximum number of columns in a table.

    [...]



    Maximum Number Of Columns



    The SQLITE_MAX_COLUMN compile-time parameter is used to set an upper bound on:




    • The number of columns in a table

    • The number of columns in an index

    • The number of columns in a view

    • The number of terms in the SET clause of an UPDATE statement

    • The number of columns in the result set of a SELECT statement

    • The number of terms in a GROUP BY or ORDER BY clause

    • The number of values in an INSERT statement


    The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.







    share|improve this answer


























    • What is the procedure to change the default value of SQLITE_MAX_COLUMN?

      – Vishnu CB
      Nov 1 '18 at 9:26



















    0














    As specified in Limits In SQLite:




    The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.




    You will have to compile SQLite with the corresponding compile-time option SQLITE_MAX_COLUMN as described in How To Compile SQLite



    I downloaded and unpacked the snapshot version from the Download page,




    • First ran ./configure and

    • Waited till the Makefile had been created

    • Opened the Makefile and added -DSQLITE_MAX_COLUMN=32767 to the end of the line starting DEFS = and saved the file.

    • Finally, ran make to compile the binary (this is for Linux/macOS/*nix, though)




    For an edge case I also had to increase the following options (none of this is recommended)



    -DSQLITE_MAX_COLUMN=32767 -DSQLITE_MAX_SQL_LENGTH=1073741824 -DSQLITE_MAX_LENGTH=1273741824 -DSQLITE_MAX_FUNCTION_ARG=127 -DSQLITE_MAX_VARIABLE_NUMBER=65534






    share|improve this answer








    New contributor




    iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "182"
      };
      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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f221508%2fhow-to-increase-column-limit-of-a-table-in-sqlite%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      You would have to obtain the Source Code for SQLLite, change the value of SQLITE_MAX_COLUMN, recompile the code and distrbute the resulting executable.



      However, more than 2000 columns in a single table sounds wrong to me.
      Do you have lots of repeated fields in each row? That's poor Relational design.



      If necessary, create a second table with the same primary key as the first and add your additional fields into that. You would have to issue two select statements to retrieve the values, though, because SQLITE_MAX_COLUMNS also applies to select statements, so you can't just join the two tables together.






      share|improve this answer




























        1














        You would have to obtain the Source Code for SQLLite, change the value of SQLITE_MAX_COLUMN, recompile the code and distrbute the resulting executable.



        However, more than 2000 columns in a single table sounds wrong to me.
        Do you have lots of repeated fields in each row? That's poor Relational design.



        If necessary, create a second table with the same primary key as the first and add your additional fields into that. You would have to issue two select statements to retrieve the values, though, because SQLITE_MAX_COLUMNS also applies to select statements, so you can't just join the two tables together.






        share|improve this answer


























          1












          1








          1







          You would have to obtain the Source Code for SQLLite, change the value of SQLITE_MAX_COLUMN, recompile the code and distrbute the resulting executable.



          However, more than 2000 columns in a single table sounds wrong to me.
          Do you have lots of repeated fields in each row? That's poor Relational design.



          If necessary, create a second table with the same primary key as the first and add your additional fields into that. You would have to issue two select statements to retrieve the values, though, because SQLITE_MAX_COLUMNS also applies to select statements, so you can't just join the two tables together.






          share|improve this answer













          You would have to obtain the Source Code for SQLLite, change the value of SQLITE_MAX_COLUMN, recompile the code and distrbute the resulting executable.



          However, more than 2000 columns in a single table sounds wrong to me.
          Do you have lots of repeated fields in each row? That's poor Relational design.



          If necessary, create a second table with the same primary key as the first and add your additional fields into that. You would have to issue two select statements to retrieve the values, though, because SQLITE_MAX_COLUMNS also applies to select statements, so you can't just join the two tables together.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 1 '18 at 11:29









          Phill W.Phill W.

          61131




          61131

























              1














              As per SQLite documentation Limits In SQLite




              "Limits" in the context of sizes or quantities that can not be exceeded. We are concerned with things like the maximum number of bytes in a BLOB or the maximum number of columns in a table.

              [...]



              Maximum Number Of Columns



              The SQLITE_MAX_COLUMN compile-time parameter is used to set an upper bound on:




              • The number of columns in a table

              • The number of columns in an index

              • The number of columns in a view

              • The number of terms in the SET clause of an UPDATE statement

              • The number of columns in the result set of a SELECT statement

              • The number of terms in a GROUP BY or ORDER BY clause

              • The number of values in an INSERT statement


              The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.







              share|improve this answer


























              • What is the procedure to change the default value of SQLITE_MAX_COLUMN?

                – Vishnu CB
                Nov 1 '18 at 9:26
















              1














              As per SQLite documentation Limits In SQLite




              "Limits" in the context of sizes or quantities that can not be exceeded. We are concerned with things like the maximum number of bytes in a BLOB or the maximum number of columns in a table.

              [...]



              Maximum Number Of Columns



              The SQLITE_MAX_COLUMN compile-time parameter is used to set an upper bound on:




              • The number of columns in a table

              • The number of columns in an index

              • The number of columns in a view

              • The number of terms in the SET clause of an UPDATE statement

              • The number of columns in the result set of a SELECT statement

              • The number of terms in a GROUP BY or ORDER BY clause

              • The number of values in an INSERT statement


              The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.







              share|improve this answer


























              • What is the procedure to change the default value of SQLITE_MAX_COLUMN?

                – Vishnu CB
                Nov 1 '18 at 9:26














              1












              1








              1







              As per SQLite documentation Limits In SQLite




              "Limits" in the context of sizes or quantities that can not be exceeded. We are concerned with things like the maximum number of bytes in a BLOB or the maximum number of columns in a table.

              [...]



              Maximum Number Of Columns



              The SQLITE_MAX_COLUMN compile-time parameter is used to set an upper bound on:




              • The number of columns in a table

              • The number of columns in an index

              • The number of columns in a view

              • The number of terms in the SET clause of an UPDATE statement

              • The number of columns in the result set of a SELECT statement

              • The number of terms in a GROUP BY or ORDER BY clause

              • The number of values in an INSERT statement


              The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.







              share|improve this answer















              As per SQLite documentation Limits In SQLite




              "Limits" in the context of sizes or quantities that can not be exceeded. We are concerned with things like the maximum number of bytes in a BLOB or the maximum number of columns in a table.

              [...]



              Maximum Number Of Columns



              The SQLITE_MAX_COLUMN compile-time parameter is used to set an upper bound on:




              • The number of columns in a table

              • The number of columns in an index

              • The number of columns in a view

              • The number of terms in the SET clause of an UPDATE statement

              • The number of columns in the result set of a SELECT statement

              • The number of terms in a GROUP BY or ORDER BY clause

              • The number of values in an INSERT statement


              The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.








              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 1 '18 at 11:57









              hot2use

              8,12952055




              8,12952055










              answered Nov 1 '18 at 7:30









              Md Haidar Ali KhanMd Haidar Ali Khan

              3,56762340




              3,56762340













              • What is the procedure to change the default value of SQLITE_MAX_COLUMN?

                – Vishnu CB
                Nov 1 '18 at 9:26



















              • What is the procedure to change the default value of SQLITE_MAX_COLUMN?

                – Vishnu CB
                Nov 1 '18 at 9:26

















              What is the procedure to change the default value of SQLITE_MAX_COLUMN?

              – Vishnu CB
              Nov 1 '18 at 9:26





              What is the procedure to change the default value of SQLITE_MAX_COLUMN?

              – Vishnu CB
              Nov 1 '18 at 9:26











              0














              As specified in Limits In SQLite:




              The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.




              You will have to compile SQLite with the corresponding compile-time option SQLITE_MAX_COLUMN as described in How To Compile SQLite



              I downloaded and unpacked the snapshot version from the Download page,




              • First ran ./configure and

              • Waited till the Makefile had been created

              • Opened the Makefile and added -DSQLITE_MAX_COLUMN=32767 to the end of the line starting DEFS = and saved the file.

              • Finally, ran make to compile the binary (this is for Linux/macOS/*nix, though)




              For an edge case I also had to increase the following options (none of this is recommended)



              -DSQLITE_MAX_COLUMN=32767 -DSQLITE_MAX_SQL_LENGTH=1073741824 -DSQLITE_MAX_LENGTH=1273741824 -DSQLITE_MAX_FUNCTION_ARG=127 -DSQLITE_MAX_VARIABLE_NUMBER=65534






              share|improve this answer








              New contributor




              iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

























                0














                As specified in Limits In SQLite:




                The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.




                You will have to compile SQLite with the corresponding compile-time option SQLITE_MAX_COLUMN as described in How To Compile SQLite



                I downloaded and unpacked the snapshot version from the Download page,




                • First ran ./configure and

                • Waited till the Makefile had been created

                • Opened the Makefile and added -DSQLITE_MAX_COLUMN=32767 to the end of the line starting DEFS = and saved the file.

                • Finally, ran make to compile the binary (this is for Linux/macOS/*nix, though)




                For an edge case I also had to increase the following options (none of this is recommended)



                -DSQLITE_MAX_COLUMN=32767 -DSQLITE_MAX_SQL_LENGTH=1073741824 -DSQLITE_MAX_LENGTH=1273741824 -DSQLITE_MAX_FUNCTION_ARG=127 -DSQLITE_MAX_VARIABLE_NUMBER=65534






                share|improve this answer








                New contributor




                iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.























                  0












                  0








                  0







                  As specified in Limits In SQLite:




                  The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.




                  You will have to compile SQLite with the corresponding compile-time option SQLITE_MAX_COLUMN as described in How To Compile SQLite



                  I downloaded and unpacked the snapshot version from the Download page,




                  • First ran ./configure and

                  • Waited till the Makefile had been created

                  • Opened the Makefile and added -DSQLITE_MAX_COLUMN=32767 to the end of the line starting DEFS = and saved the file.

                  • Finally, ran make to compile the binary (this is for Linux/macOS/*nix, though)




                  For an edge case I also had to increase the following options (none of this is recommended)



                  -DSQLITE_MAX_COLUMN=32767 -DSQLITE_MAX_SQL_LENGTH=1073741824 -DSQLITE_MAX_LENGTH=1273741824 -DSQLITE_MAX_FUNCTION_ARG=127 -DSQLITE_MAX_VARIABLE_NUMBER=65534






                  share|improve this answer








                  New contributor




                  iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  As specified in Limits In SQLite:




                  The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.




                  You will have to compile SQLite with the corresponding compile-time option SQLITE_MAX_COLUMN as described in How To Compile SQLite



                  I downloaded and unpacked the snapshot version from the Download page,




                  • First ran ./configure and

                  • Waited till the Makefile had been created

                  • Opened the Makefile and added -DSQLITE_MAX_COLUMN=32767 to the end of the line starting DEFS = and saved the file.

                  • Finally, ran make to compile the binary (this is for Linux/macOS/*nix, though)




                  For an edge case I also had to increase the following options (none of this is recommended)



                  -DSQLITE_MAX_COLUMN=32767 -DSQLITE_MAX_SQL_LENGTH=1073741824 -DSQLITE_MAX_LENGTH=1273741824 -DSQLITE_MAX_FUNCTION_ARG=127 -DSQLITE_MAX_VARIABLE_NUMBER=65534







                  share|improve this answer








                  New contributor




                  iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 21 mins ago









                  iolsmitiolsmit

                  1011




                  1011




                  New contributor




                  iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  iolsmit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Database Administrators Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f221508%2fhow-to-increase-column-limit-of-a-table-in-sqlite%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Ronny Ackermann

                      Köttigit

                      MySQL 8.0.15 starts normally but any connection hangs