Re: [EXTERNAL] char(0) with SQLite

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] char(0) with SQLite

Hick Gunter
Dimensions are ignored by SQLite. A field defined CHAR(0) can hold any length (up to the internal limit) of string. SQlite will only store the actual length of the string plus its contents, no space  is wasted.

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Grincheux
Gesendet: Sonntag, 01. September 2019 08:14
An: [hidden email]
Betreff: [EXTERNAL] [sqlite] char(0) with SQLite

Into my db I store passwords having differents lengths (from 1 to 50).
I don't want to give the max size that woud be using space I don't need.
I found that sqlite permits char(0) but what is the incidence for my db.



--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] char(0) with SQLite

Olivier Mascia
> Le 2 sept. 2019 à 12:12, Hick Gunter <[hidden email]> a écrit :
>
>> Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Grincheux
>> Into my db I store passwords having differents lengths (from 1 to 50).
>> I don't want to give the max size that woud be using space I don't need.
>> I found that sqlite permits char(0) but what is the incidence for my db.
> Dimensions are ignored by SQLite. A field defined CHAR(0) can hold any length (up to the internal limit) of string. SQlite will only store the actual length of the string plus its contents, no space is wasted.

Grincheux,

As Hick wrote, dimensions are ignored.  You don't even need to use CHAR(0). CHAR(1000) or CHAR or TEXT (often used in SQLite schemas) will do and are all equivalents.  If CHAR(50) makes sense for you, as a documentation hint that you don't expect ever more than 50 characters, then there is nothing wrong leaving it as such in your schema. If you want to enforce the 50 characters limit, you have to do it either in your code using SQLite OR through some CHECK on the SQL definition.

—  
Best Regards, Meilleures salutations, Met vriendelijke groeten, Mit besten Grüßen,
Olivier Mascia


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] char(0) with SQLite

Dominique Devienne
In reply to this post by Hick Gunter
On Mon, Sep 2, 2019 at 12:12 PM Hick Gunter <[hidden email]> wrote:

> Dimensions are ignored by SQLite. A field defined CHAR(0) can hold any
> length (up to the internal limit) of string. SQlite will only store the
> actual length of the string plus its contents, no space  is wasted.


And Gunter wrote "string" above, but SQLite will also hold an integer, or
real, or blob value in that row/col (i.e. cell) just as well :) --DD

PS: Note that if you use the text type for your password, note that the
text is expected to be UTF-8.
If you users use accented characters in an 8-bit encoding, and you do not
properly convert that
into UTF-8, this could perhaps create issues (although if you take that
UTF-8, and manipulate it
assuming the same 8-bit encoding, SQLite should give you back the same
bytes, it doesn't do
UTF-8 validation AFAIR). Otherwise use a blob and conventions/assumptions
in your app.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users