Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create Table With Default Values

    Hello! I have the following code that creates a table structure. How do I give Age a default value of 0

    Code:
    mysql_select_db("DB", $connection);
    $sql = "CREATE TABLE Person
    (
    Name text,
    Age text,
    Sex text
    )";

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Look up the MySQL reference manual.

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by Cerby View Post
    Hello! I have the following code that creates a table structure. How do I give Age a default value of 0

    Code:
    mysql_select_db("DB", $connection);
    $sql = "CREATE TABLE Person
    (
    Name text,
    Age text,
    Sex text
    )";

    Sorry that is Soooo Wrong
    one thing Mysql dose not knwo what text is

    Varchar - Has to be followed by the ammount of diggets used

    And there is nothing there telling mysql there is a deafult no. as far as it is conserned they all are allowed Vale of NULL

    If you google PHP MYSQL Create Table - you will get some good tutorial
    and for Defaults Serch MYSQL DEFAULT btw hate to say this but check this site out
    http://www.just****inggoogleit.com

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by barkermn01 View Post
    Mysql dose not knwo what text is
    Yes, MySQL does.

  • #5
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by Inigoesdr View Post
    Sorry Vesion 5.1 Dose
    4.5 - Most Web servers still running Dosent there is varchar or Memo
    And from what i read about text from read about Text is stors Data Verry big i say stick with memo for texts over and not to mension

    Users VARCHAR(255)
    Or
    Users MEMO
    Or
    c2 TEXT CHARACTER SET latin1 COLLATE latin1_general_cs - hrm with 2 are easyer to write
    That form your own link mate read befor you post
    Last edited by barkermn01; 11-16-2007 at 11:47 AM.

  • #6
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    4.5 - Most Web servers still running Dosent there is varchar or Memo
    All my hosts run at least 5.1. And I remember using the Text type since at least 4, but I might be wrong.

    And there is nothing there telling mysql there is a deafult no. as far as it is conserned they all are allowed Vale of NULL
    Hence the person asking the question.

    And whether it is allowed NULL or not has nothing to do with the question.

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by aedrin View Post
    And I remember using the Text type since at least 4, but I might be wrong.
    No, you're right. It's in MySQL 4 too.


  •  

    Posting Permissions

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