sql alter help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • leegold2

    #1

    sql alter help

    mysql> describe keywords;
    +-------------+------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +-------------+------------------+------+-----+---------+----------------+
    | page_id | int(10) unsigned | | PRI | NULL | auto_increment |
    | keyword_txt | text | YES | | NULL | |
    +-------------+------------------+------+-----+---------+----------------+
    2 rows in set (0.01 sec)


    How do I alter these fields w/SQL so that they can not be null?

    Thanks
  • steve

    #2
    Re: sql alter help

    "leegold2" wrote:[color=blue]
    > mysql> describe keywords;
    >[/color]
    +-------------+------------------+------+-----+---------+-------------
    ---+[color=blue]
    > | Field | Type | Null | Key | Default | Extra[/color]
    [color=blue]
    > |
    >[/color]
    +-------------+------------------+------+-----+---------+-------------
    ---+[color=blue]
    > | page_id | int(10) unsigned | | PRI | NULL |
    > auto_increment |
    > | keyword_txt | text | YES | | NULL |[/color]
    [color=blue]
    > |
    >[/color]
    +-------------+------------------+------+-----+---------+-------------
    ---+[color=blue]
    > 2 rows in set (0.01 sec)
    >
    >
    > How do I alter these fields w/SQL so that they can not be null?
    >
    > Thanks[/color]

    I am sure someone else will give you the exact solution....

    But for me, being lazy, I fire up phpmyadmin, and simply use the GUI
    to change the field default to not null, and then phpmyadmin shows me
    the exact sql that it executed.

    --
    http://www.dbForumz.com/ This article was posted by author's request
    Articles individually checked for conformance to usenet standards
    Topic URL: http://www.dbForumz.com/mySQL-sql-al...ict146886.html
    Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=492952

    Comment

    • Bart Van der Donck

      #3
      Re: sql alter help

      leegold2 wrote:
      [color=blue]
      > mysql> describe keywords;
      > +-------------+------------------+------+-----+---------+----------------+
      > | Field | Type | Null | Key | Default | Extra |
      > +-------------+------------------+------+-----+---------+----------------+
      > | page_id | int(10) unsigned | | PRI | NULL | auto_increment |
      > | keyword_txt | text | YES | | NULL | |
      > +-------------+------------------+------+-----+---------+----------------+
      > 2 rows in set (0.01 sec)
      >
      > How do I alter these fields w/SQL so that they can not be null?[/color]

      ALTER TABLE keywords CHANGE page_id page_id INT(10) NOT NULL;
      ALTER TABLE keywords CHANGE keyword_txt keyword_txt TEXT NOT NULL;

      Bart

      Comment

      Working...