Table is not altering

I have two tables in my wordpress database.

$table_name1='objectives';

$table_name2='implementation-how';  

Now I want to alter these tables.So I am using “dbDelta” function to alter these tables.My $table_name1 is altered successfully,but $table_name2 is not altering.Can anyone suggest what is I am missing.I am using following code

Read More
$table_name1='objectives';
    $sql= "CREATE TABLE $table_name1 (
    `objectiveID` int(11) unsigned NOT NULL AUTO_INCREMENT,
     `catID` int(11) NOT NULL,
     `objective` varchar(250) NOT NULL DEFAULT '',
     `evalMeasure` varchar(250) NOT NULL DEFAULT '',
      PRIMARY KEY (`objectiveID`)
    ) $charset_collate;";
    dbDelta( $sql );

and

$table_name2='implementation-how';  
     $sql= "CREATE TABLE $table_name2 (
    `howID` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `strategyID` int(11) NOT NULL,
    `how` varchar(250) NOT NULL DEFAULT '', 
     ADD `is_default` int(11 ) NOT NULL DEFAULT '1',
      ADD `userID` int(11),
    PRIMARY KEY (`howID`)
    ) $charset_collate;";
     dbDelta( $sql );

Related posts

2 comments

  1. check this . when creating tables ,table name can’t use ‘-‘ symbols (reserved symbols)

    $table_name2='implementationhow';  
         $sql= "CREATE TABLE $table_name2 (
        `howID` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `strategyID` int(11) NOT NULL,
        `how` varchar(250) NOT NULL DEFAULT '', 
         `is_default` int(11 ) NOT NULL DEFAULT '1',
         `userID` int(11),
        PRIMARY KEY (`howID`)
        ) ";
    
    dbDelta( $sql );
    
  2. use that code

      $table_name2='implementation_how';  
        CREATE TABLE $table_name2 (
        `howID` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `strategyID` int(11) NOT NULL,
        `how` varchar(250) NOT NULL DEFAULT '', 
         `is_default` int(11 ) NOT NULL DEFAULT '1',
          `userID` int(11),
        PRIMARY KEY (`howID`) ) ";
    dbDelta( $sql );
    

Comments are closed.