On Tue, Sep 22, 2009 at 8:39 AM, Angus March <an...@uducat.com> wrote: > P Kishor wrote: >> On Mon, Sep 21, 2009 at 5:10 PM, Guillermo Varona Silupú >> <gvaro...@hotmail.com> wrote: >> >>> Hi >>> In these SQL commands: >>> >>> CREATE TABLE "test" ("code" char(2)); >>> INSERT INTO test (code) VALUES("123") >>> >>> Why are allowed to keep a text of 3 characters in a field that has been >>> set to 2? >>> Is a bug? >>> >> >> >> nope. It is by design. Read up on datatypes in sqlite. If you are >> concerned about what goes where, you have to put the checks in your >> application. >> > > One thing that I haven't been able to find explicitly is there is no > advantage to using CHAR(2). In my db I have blobs and strings that are > of an exact length, but I don't bother declaring them as anything but > BLOB and TEXT, since I don't expect it'll optimize anything. So can > someone confirm for me that CHAR(2) does nothing for efficiency and > everything for compatibility?
Yes, you are correct. If I understand correctly, SQLite is pretty intelligent about allocating just enough space for your data, kinda like varchar, no matter what length you declare. -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science ======================================================================= Sent from Madison, WI, United States _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users