What is a table?
A database is like a filing cabinet. A table is a drawer in it. A table looks like a spreadsheet. It has columns, which are the headings, and rows, which are the entries. For example, a "friends" table could have the columns name, phone and birthday. Each friend is one row.
phpMyAdmin is a web tool for managing databases. You can open it from cPanel, the control panel for your hosting.
Steps
- Log in to your client area. Open your hosting service and log in to cPanel.
- Under Databases, click phpMyAdmin.
- Click your database name on the left. If you have none, create one first in MySQL Databases.
- Find the Create table box.
- Type a table name, for example
friends. - Type the number of columns you need, for example 3.
- Click Go (or Create).
- Fill in one line for each column:
- Name: the column heading, like
name. - Type: the kind of data. Use INT for whole numbers, VARCHAR for short text, TEXT for long text, and DATE for dates.
- Length/Values: the maximum size. For VARCHAR, type a number like 100.
- Name: the column heading, like
- Make an ID column. Set its type to INT. Under Index, choose PRIMARY. Tick A_I, which means auto increment. Now each row gets its own number by itself.
- Click Save.
The new table now shows in the left list.
Add a row
- Click your table name.
- Click the Insert tab.
- Type values into the boxes. Skip the ID, because it fills in itself.
- Click Go.
Create with SQL
You can also use the SQL tab:
CREATE TABLE friends (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
phone VARCHAR(20)
);
This makes a table named friends with three columns.
Tip: Use lowercase names without spaces. Use underscores instead, like
first_name.Quick recap
- A table holds data in rows and columns.
- Choose your database, then use the Create table box.
- Set a name and a type for every column.
- Give each table an ID column with PRIMARY and A_I.
- Click Save.