SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What does default '0' mean?

    In the following SQL what does the default '0' mean?
    Code:
     category_name varchar(50) NOT NULL default '0',

  2. #2
    SitePoint Zealot jb007irl's Avatar
    Join Date
    Jun 2003
    Location
    Ireland
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Googly
    In the following SQL what does the default '0' mean?
    Code:
     category_name varchar(50) NOT NULL default '0',
    Think it means that because your category_name field cannot be NULL that you mush give it a default value and that value is set to 0.
    Is minic a bhris béal duine a shrón.

  3. #3
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly - if you do not enter anything for that field when creating a new row it will have a default value of zero.

  4. #4
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And if you don't set this value to default '0' what happens when you insert a row?

  5. #5
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you do not set a value MYSQL will automatically insert a zero for you.

  6. #6
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So in MySql it's not really needed?

  7. #7
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It depends on your particular requirements for you database whether you use it - it is a feature which can be used or not - your choice!

  8. #8
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks


Bookmarks

Posting Permissions

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