SyuTingSong / phpliteadmin

Automatically exported from code.google.com/p/phpliteadmin
0 stars 0 forks source link

Add VARCHAR #160

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to be able to choose 'VARCHAR' as data type and specify a length.

Original issue reported on code.google.com by swenko...@gmail.com on 26 Nov 2012 at 6:04

GoogleCodeExporter commented 9 years ago
Well, the easy answer is: Use another DBMS then ;-)

SQLite does not use this information if you specify it. You can specify it, but 
it will simply be ignored. From http://www.sqlite.org/faq.html#q9 :

SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) 
and SQLite will be happy to let you put 500 characters in it. And it will keep 
all 500 characters intact - it never truncates.

So I would say it does not make any sense to specify a field VARCHAR(10). This 
will only create the wrong impression that the string cannot be longer.

In fact there usually is a maximum length of one billion for any TEXT or BLOB 
field specified by a preprocessor macro (at compile time!):
http://www.sqlite.org/limits.html#max_length

To ensure that a string cannot be larger, you can use a CHECK constraint (which 
will raise a constraint violataion if the length is too large - not truncate 
it!) or use a trigger.

So these remarks to help you with SQLite. I don't see anything phpLiteAdmin 
should implement in this regard.
Only thing I could image would be to implicitely create a trigger checking the 
length if somebody created a VARCHAR of a given length. But users who know 
SQLite would expect that the specified length is weak, which would be wrong 
then.

Original comment by crazy4ch...@gmail.com on 26 Nov 2012 at 7:47

GoogleCodeExporter commented 9 years ago
Ah, and if you follow the SQLite logic: Don't consider it a bug - it's a 
feature!
You'll never get the problem that data gets truncated.

I really meant my first sentence seriously. If you don't like the way SQLite 
does things, better use a more sophisticated DBMS (postrgeSQL or MySQL (with 
InnoDB) for example). I heard there is a fairly popular web-GUI available for 
MySQL as well ;-)

Original comment by crazy4ch...@gmail.com on 26 Nov 2012 at 8:00

GoogleCodeExporter commented 9 years ago
As long as nobody gives a good reason why this makes sense, I'll mark it as 
"Won't fix."

Original comment by crazy4ch...@gmail.com on 28 Nov 2012 at 10:56

GoogleCodeExporter commented 9 years ago
Issue 165 has been merged into this issue.

Original comment by crazy4ch...@gmail.com on 12 Jan 2013 at 7:13