MySQL with phpMyAdmin Tutorial
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.
- 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.
- 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.
- Name the rest of the fields and select their types.
- 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.
- 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.
- 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.
- A prompt asks you to confirm your decision.
Tips & Tricks
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.