62354

Sqlite Dropping Column from table

Question:

Why sqlite database has the limitation of "not to drop a column from a table" in a single command? Are there any chances it would be added in future versions?

Answer1:

<blockquote>

SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. It is not possible to rename a column, remove a column, or add or remove constraints from a table.

</blockquote>

<a href="https://sqlite.org/lang_altertable.html" rel="nofollow">https://sqlite.org/lang_altertable.html</a>

No, you can't.

<blockquote>

Are there any chances it would be added in future versions?

</blockquote>

Well, we can't tell you that. And even if they will add it, there are still a lot of Android devices out there which have an older version of SQLite without that feature.

However, you can delete a column like this from this answer:

<a href="https://stackoverflow.com/a/5987838/5457878" rel="nofollow">https://stackoverflow.com/a/5987838/5457878</a>

Answer2:

The ALTER TABLE statement supports exactly those operations that can be implemented easily without having to rewrite the entire table. (When adding a new column, that value is missing in all rows; it gets replaced with the column's default value when read.)

The ability to drop columns (or other things, like reordering columns) would add lots of complex code to the SQLite library. However, SQLite is designed as an embedded database, so it must take care to conserve resources. It is very unlikely that such a large amount of code will ever be added.

Answer3:

<a href="http://www.sqlite.org/faq.html#q11" rel="nofollow">http://www.sqlite.org/faq.html#q11</a>

<blockquote>

SQLite has limited ALTER TABLE support that you can use to add a column to the end of a table or to change the name of a table. If you want to make more complex changes in the structure of a table, you will have to recreate the table. You can save existing data to a temporary table, drop the old table, create the new table, then copy the data back in from the temporary table.

</blockquote>

So you can't just delete the column

Recommend

  • Insert null in a database
  • SVG Fill Width to Child Elements
  • mapping between words and a group tuple to get frequency of words
  • Mod rewrite redirection to another domain if file not exist
  • Redis under Classic ASP(VBScript)
  • How to give custom name to Sqoop output files
  • SSH in Bash Script Messing Up File Read
  • Doctrine2 inverse persistance not working in nested forms
  • How many Vertica Databases can run on a Host in the same time?
  • How to create virtual printer with iOS Simulator?
  • Distributed JMS based logging .. falling flat?
  • What is this strange character in chrome's resource css viewer?
  • Application bar icon text length
  • Regex for Specific Tag
  • apply a javascript function to draggable copy
  • How can we prepend rows to a react native list-view?
  • Android changing fragment order inside FragmentPagerAdapter
  • What's the purpose of QString?
  • Create DicomImage from scratch using Dcmtk
  • Groovy: Unexpected token “:”
  • Jackson Parser: ignore deserializing for type mismatch
  • Installing Apache MyFaces 2 on WildFly 8.2.0
  • With Hadoop, can I create a tasktracker on a machine that isn't running a datanode?
  • ImageMagick, replace semi-transparent white with opaque white
  • Cannot connect to cassandra from Spark
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Regex thinks I'm nesting, but I'm not
  • What is the “return” in scheme?
  • RectangularRangeIndicator format like triangular using dojo
  • Cross-Platform Protobuf Serialization
  • ILMerge & Keep Assembly Name
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • How to disable jQuery.jplayer autoplay?
  • Revoking OAuth Access Token Results in 404 Not Found
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • UserPrincipal.Current returns apppool on IIS