create a table - mysql

Discussion in 'MySQL' started by martinvidic, Apr 5, 2007.

  1. #1
    Hi.... can anybody change this line for me :)

    `id` varchar(11) NOT NULL,

    I want to change it so that the id can be a very very long url....
    SO it has to be defined different right....????

    Thanx.
    M.V.
     
    martinvidic, Apr 5, 2007 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just define it as "text" and you can have it as long as you like.
     
    maiahost, Apr 5, 2007 IP
  3. druidelder

    druidelder Peon

    Messages:
    285
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How long are we talking about? You could just change the varchar to something like varchar(4000). The beauty of the varchar is that you don't have to worry about the extra memory. It only allots as much as is needed for the data (not the definition).
     
    druidelder, Apr 5, 2007 IP
  4. martinvidic

    martinvidic Guest

    Messages:
    182
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think the logest url will be about 150 or 200 letters.
    but maybe the problem are signs like "http://^*`+-...¨etc.

    How to i define as text... and will it allow //

    thanx mv
     
    martinvidic, Apr 5, 2007 IP
  5. druidelder

    druidelder Peon

    Messages:
    285
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #5
    'id' text NOT NULL
     
    druidelder, Apr 5, 2007 IP
  6. Clive

    Clive Web Developer

    Messages:
    4,507
    Likes Received:
    297
    Best Answers:
    0
    Trophy Points:
    250
    #6
    Just to make it clear, varchar() field type can store up to a max of 255 characters.
    if you need more than that, you go for mediumtext or text.
     
    Clive, Apr 5, 2007 IP
  7. martinvidic

    martinvidic Guest

    Messages:
    182
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ok... i got the problem with the length now...
    But i cant make IDs as urls, becasue of the dots and slashes.
     
    martinvidic, Apr 5, 2007 IP
  8. Clive

    Clive Web Developer

    Messages:
    4,507
    Likes Received:
    297
    Best Answers:
    0
    Trophy Points:
    250
    #8
    Just use maiahost's advice then..
     
    Clive, Apr 5, 2007 IP
  9. druidelder

    druidelder Peon

    Messages:
    285
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #9
    That is a MySQL limitation? (varchar 255) I was not aware of that. I mainly use MS-SQL and the max length is much larger.

    I just found it. Starting in MySQL 5.0.3 the max length for varchar is 65K and 255 before that. Learn something new everyday.
     
    druidelder, Apr 6, 2007 IP