If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Other PC Databases > 2 database related questions here..

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-24-10, 11:22
Theresonly1 Theresonly1 is offline
Registered User
 
Join Date: Nov 2009
Posts: 24
Question 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?
Reply With Quote
  #2 (permalink)  
Old 01-24-10, 12:00
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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.

Quote:
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

Quote:
The database i'm using
and why is that a secret?
Reply With Quote
  #3 (permalink)  
Old 01-24-10, 23:20
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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.
Reply With Quote
  #4 (permalink)  
Old 01-25-10, 09:50
Theresonly1 Theresonly1 is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On