Please consider downloading the latest version of Internet Explorer
to experience this site as intended.
Meloria • Ever Better
Search Tools Main Menu

MySQL with phpMyAdmin Tutorial

Index | Getting Started | Tables | Viewing Data | Updating Data | Resources

Creating and Modifying a Table

Creating a Table

  • Select a database from the drop-down menu.
  • Find "Create new table on database . . .", which is located near the bottom of the page.
    create new table box
  • Enter the table's name in the "name" field.
  • Enter the number of fields next to "fields". You can always add or modify fields later.
  • Click "Go"
  • Each row on this page represents a field.
    columns setup
  • The first field should be some type of numeric id.
    • The id field is important because it may be the only field that is unique to each table entry.
    • Enter the field's name under "Field".
    • Since this is a numeric field, set its Type to INT (integer).
    • Since you won't need negative numbers for the id, set the Attributes option to unsigned.
    • If you plan on having ids in sequential order, set the Extra option to auto-increment.
    • Select the primary radio button.
  • A datetime field should be used if you want to store the date and time that information was submitted.
    an example of a datetime field, datesubmitted
  • Name the rest of the fields and select their types.
    more example fields for columns setup
  • Use varchar for short pieces of text like names.
  • Use text for longer text like a paragraph.
  • Use datetime for storing the year, month, day and time.
  • Use date when the date is needed, but not the time.

Modifying a Table

  • To add a new field, enter the number of fields to add next to "Add a new field", select a location from field list, and press Go.
    add new field box
  • You can modify an existing field by clicking on the change link next to any field name or by checking multiple fields and pressing the change button.
    table structure display
  • To delete a field, use the drop link or button instead.

Deleting a Table

  • To delete the table you are currently viewing, click the drop link at the top-right of the page.
    delete tab
  • A prompt asks you to confirm your decision.
    delete tab

Tips & Tricks

The NULL value confuses newcomers to SQL, who often think that NULL is the same thing as an empty string. But thats not the case. By typing in Null, you have given a value to the field. However, by not typing anything to the field will return an empty string.