4 Replies Latest reply on Apr 29, 2008 7:30 AM by (Paul_B._Kelley)

    MySQL question regarding default values

    Level 1
      For the contacts management tutorial the contacts table ('contact_con') lists data for names as:

      `name_con` varchar(50) NOT NULL default ''

      However, in the PHPAdmin panel the "default" field is referenced by a footnote which reads: "For default values, please enter just a single value, without backslash escaping or quotes, using this format: a

      Does this mean that the default field is simply left blank, or as PHPAdmin puts it, left blank "without [...] quotes"? If so, why include these quotes in the SQL dump?
        • 1. Re: MySQL question regarding default values
          Günter Schenk Level 4
          Hi Paul,

          -----
          If so, why include these quotes in the SQL dump?
          -----

          without the '' (which is an alias for "blank") quotes MySQL will throw an error

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: MySQL question regarding default values
            Level 1
            Exported contacts table as created by using the PHPadmin gui interface:

            CREATE TABLE IF NOT EXISTS `contact_con` (
            `id_con` int(11) NOT NULL auto_increment,
            `idcom_con` int(11) NOT NULL default '0',
            `name_con` varchar(50) NOT NULL,
            `job_con` varchar(100) NOT NULL,
            `email_con` varchar(255) NOT NULL,
            `phone_con` varchar(30) NOT NULL,
            `birthday_con` date default NULL,
            PRIMARY KEY (`id_con`)
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;

            If this is incorrect, how does one enter a blank default value in the values field 'for 'name_con' (for instance) by using the PHPadmin gui, when it specifically instructs not to use quotes for this field?
            • 3. Re: MySQL question regarding default values
              Günter Schenk Level 4
              Paul,

              *if* you specify a default blank value for text columns (e.g. varchar) in your sql dump, you will have to use those quotes, and that´s the correct way to do that -- but it´s of course up to you to omit specifying a default blank default value.

              Providing an SQL dump that´s going to be inserted into PhpMyAdmin is different from how things can be specified when working with PhpMyAdmin directly.

              -----
              If this is incorrect, how does one enter a blank default value in the values field 'for 'name_con' (for instance) by using the PHPadmin gui
              -----

              just leave the default value field empty, and PhpMydmin will care for the rest.

              ------
              when it specifically instructs not to use quotes for this field?
              ------

              because you don´t have to add those quotes when working with PhpMyAdmin directly :-)

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: MySQL question regarding default values
                Level 1
                Thanks, Gunter, that's what I figured. I appreciate your patience.