Google

MySQLMan Help


Tool bar     HOME

Define Column Structure

After having specified the name of the table to be created or the number of fields to add to existing table, you will be prompted to define the structure of the table. The number of rows of the form will equal to the number fields you specified in the previous page. Fill the fields accordingly to specify the structure of the table and press "Create Table"/"Add Column" to create the table/add the columns. Please note that all rows must be filled, otherwise an error will occur.

For more details regarding to CREATE TABLE... query, please refer to mySQL online reference at http://www.mysql.com/Manual_chapter/manual_Reference.html#CREATE_TABLE

For more details regarding to ALTER TABLE... ADD [COLUMN]... query, please refer to mySQL online reference at http://www.mysql.com/Manual_chapter/manual_Reference.html#ALTER_TABLE

  • The form
      Field
      Put field names here. For details on legal names, please refer to mySQL online manual at http://www.mysql.com/Manual_chapter/manual_Reference.html#Legal_names

      Type
      Specify the column types here from the list. For details on column types, please refer to http://www.mysql.com/Manual_chapter/manual_Reference.html#Column_types

      Length/Set
      For types like CHAR or INT, you will need to specify lengths for them. To have INT(10), you should have 'INT' selected under column Type and '10' under column Length/Set.

      If a field is given a type SET or ENUM, then you need to specify the options here as well. You must quote each option with single quotes and escape characters with a back-slashes (\). In addition. the options should be separated by commas. Please refer to the end of the page for an example.

      Attributes
      Attributes for numeric types

      Null
      NUll if null values are allowed in the field, NOT NULL otherwise.

      Default
      Default value for the field.

      Extra
      Set the field auto_increment.

      Primary/Index/Unique
      Check the checkboxes to make the fields primary/index/unique keys.

  • An example
    To create a table with the following query
    CREATE TABLE new_table (
       ID int(10) unsigned NOT NULL auto_increment,
       Color enum('red','blue','yellow') NOT NULL,
       Features set('A\\C','power lock'),
       PRIMARY KEY (ID)
    )
    Fill the form as follows:
    (Note that you need to escape '\' with '\' in column Length/Set for field 'Features')
Tool bar     HOME
Related topics: Create table , Add fields