In PHPMyAdmin, it actually provides a UI for us to create a table.
Let’s try to create a table with 3 columns.
But before we can have a table, we would need to create a database first.
1. In PHPMyAdmin, click on NEW in the left panel
2. Give the database a name, for now we call it Artist. Enter Artist in the textbox under Create Database.
3. Click on create to create the database Artist.
4. Now that we have the Artist database create, click on it on the left panel and we would have a screenshot as below.
6. We can now create the table. Let’s create a table called Album with 3 columns.
7. The 3 columns are for Name, Title and Year.
8. Enter Album for Name and 3 for Number of Columns as shown in the screenshot above.
9. Click on Go.
10. After click Go, you will see a screenshot as below.
11. This screenshot is for us to enter the column info.
12. For Name, we give it a varchar with length 64 chars, Title with 256 chars. For Year, we will use Integer and so length is not needed.
13. Click on Save to create the table.
14. Now we have a album table with 3 columns created.
16. We can insert a record to test it.
17. Click on SQL on the tab and Insert
18. An Insert statement will be automatically created for us.
INSERT INTO `album`(`Name`, `Title`, `Year`) VALUES ([value-1],[value-2],[value-3])
19. We just have to make some changes to this statement to insert a record.
20. Modify it to below sql insert statement
INSERT INTO `album`(`Name`, `Title`, `Year`) VALUES ('Rod Stewart','Every Picture Tells A Story',1969)
21. A record will be inserted into the table.