Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Posts
    24

    Question Unanswered: 2 database related questions here..

    Hello

    Dont want to spam with too many posts so just posting my 2 questions as an one topic.

    1) what is the best way to file paths? For example..
    "C:/Users/Admin/...../..../...

    Don't know what is the maximum size i should give to my data-type. The database i'm using doesn't have a TEXT datatype like MYSQL does so i probably need to use a VARCHAR with a size.

    2) When comparing CHAR against VARCHAR with '=' sometimes it doesn't work, it says i need a cast.. But when i use the 'LIKE' operator - it works.. Why is that?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by Theresonly1 View Post
    Don't know what is the maximum size i should give to my data-type.
    Well that should be the max. size of a path in whatever operating system you want the path to be valid. In Windows there is a limit that can probably be found out by searching the Microsoft website. For any *nix system this depends on the file system used.

    2) When comparing CHAR against VARCHAR with '=' sometimes it doesn't work, it says i need a cast.. But when i use the 'LIKE' operator - it works.. Why is that?
    The CHAR datatype stores values padded with blanks so a CHAR(10) is always 10 characters long. If you store 'HELLO' into such a column, the DBMS will add 5 spaces to the end of the value.
    Those spaces will be taken into account when comparing values ('HELLO' is different from 'HELLO ')

    My recommendation: don't use CHAR unless you really know that the length of your data is fixed

    The database i'm using
    and why is that a secret?

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    1) That's a good way to store paths. The length of a path is limited by either the Operating System, the File System, or the Device Driver. The limits that I've seen are 32 characters to 1023 characters. Most modern systems store filenames using a large character set (such as Unicode, UTF-8, etc) and most archaic systems use single byte characters.

    Pick a length that suits you, almost any value will cause problems somewhere!

    3) As Shammat pointed out, CHAR() columns space fill on the right. CHAR() comparisons are tricky for many reasons, I would avoid them until you have the time to learn in detail how they work.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  4. #4
    Join Date
    Nov 2009
    Posts
    24

    Thumbs up

    Quote Originally Posted by shammat View Post
    and why is that a secret?
    No not a secret at all.

    I was at that point using Apache-Derby but now i have switched to SQLite.

    thanks for answers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •