[yunqa.de] Field sizes - SQLite tables

  • From: Hal Corbould <hal.corbould@xxxxxxxxxxxx>
  • To: Junker R - via Freelist <yunqa@xxxxxxxxxxxxx>
  • Date: Sun, 10 May 2009 09:30:35 +1000

I am transferring eight tables in a MySQL database intended for the public domain to SQLite. I am using DISQLite3. I am concerned about table field design and sizes.


I started by re-creating the simplest table in the MySQL database - a list of currency codes and names.

I created a new database and then a table using SQLiteSPy 1.8.9.
create table tcurr (
currcode char(3) not null unique default ZZZ,
currname char(30) not null default Name,
primary key (currcode)
)

I populated the table with eg
insert into tcurr (currcode,currname) values ('CAD','Canadian dollar');
insert into tcurr (currcode,currname) values ('USD','US dollar');
insert into tcurr (currcode,currname) values ('HKD','Hong Kong dollar78201234567830');
insert into tcurr (currcode,currname) values ('AUD','Australian dollar');
insert into tcurr (currcode,currname) values ('EUR','Euro');

All ok.

I then revised DISQLite3_ClientDataSet_Grid.dpr to read in the new tcurr table and display it for additions and editing. I found that while I could add new 3-char codes, the currname field would display only 20 chars (the HKD name was truncated), and would not accept any new currname text longer than 20 chars.

Using SQLiteSpy, I added these new currencies:
insert into tcurr (currcode,currname) values ('ZLN','Long dollar2345678201234567830'); insert into tcurr (currcode,currname) values ('ZLX','Extended dollar6782012345678301234567840'); insert into tcurr (currcode,currname) values ('ZLXABC','Extended dollar6782012345678301234567840');

These additions were successfully displayed in SQLIteSpy.

Returning to DISQLite3_ClientDataSet_Grid.exe, all currency names longer than 20 chars were truncated to 20 chars, but the six char currcode added using SQLiteSpy was fully displayed.

I then manually added one extra currency using DISQLite3_ClientDataSet_Grid.exe. This test allowed me to input QWERTY as the currcode and this was accepted when I clicked the Apply Updates button.

Could you please help with these questions:

1) Why when using SQLiteSpy will the table accept and display a currcode longer than three chars, and/or a currname longer than 30 chars?

2) Why will DISQLite3_ClientDataSet_Grid.exe accept and then display all six chars of the deliberately incorrect currency code ZLXABC when this field is set to be three chars?

3) Why will DISQLite3_ClientDataSet_Grid.exe not accept or display the full thirty chars of the currname?

Thanks.
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: