How to Create, Edit, and Delete Table Using phpMyAdmin

Previously we have discussed how to create a database with phpMyAdmin, today we’ll discuss how to create table using phpMyAdmin as well as how to edit and delete it.

Same as creating a database, creating tables also be done using a SQL query, but using phpMyAdmin or other tools, the query will be created and executed automatically, we only need to fill the parameters.

I. How to Create Table Using phpMyAdmin

To create table using phpMyAdmin, follow the following steps:

  1. Select a database that you want to create a table in, to do so, click the database name in the left panel, or click on the  database name link at the breadcrumbs, it will display a list of tables (if any) that exist in the database.
  2. In the “Create table” section (located under the tables lists), enter the name of the table and the number of columns you want to create (the number of columns can also be added later), and then click the GO button

    How to Create Table Using phpMyAdmin - The Table Name

    until this step, the table has not been created yet, we have to define the column name.

  3. Fill in the column detail.

    Creating Table Using phpMyAdmin - Fill in The Parameters

    Explanation:

    • Name: fill in the name of column, the column name should reflect the contents of the column, for example: discount, which means total discounts obtained.
    • Type: select the appropriate type. Many kind of type are available, commonly used are:
      • INTSMALLINT, BIGINT, used for numbers that will be used for arithmetical operations such as addition, multiplication, etc. for example: a discout_amount.
      • CHAR and VARCHAR are  for strings, numbers (if not used for arithmetical operations – eg zip code, phone number, etc…), letters, a combination of numbers and letters, etc., with maximum characters of 255. CHAR is used for the fixed number of characters, while VARCHAR used for non-fixed number of characters.
      • DATE: used to store date using a format: yyyy-mm-dd.
      • TEXT, LONG TEXT: for strings with more than 255 character’s length.
    • Length/Values. Required if we use CHAR or VARCHAR
    • Default: the default value of the empty field. For example: we want to insert data to into rows, but we don’t define the value of this column, then we can determine what value should be filled by MySQL: None, NULL, etc.
    • Collation. Determine what type of collation will be used, you can leave it blank mean that we’ll use the table collation.
    • Index: used it if you want to use this column as an index of the table or you can leave it blank.
    • A_I. Auto Increment Used to automatically add sequential numbers (1, 2, 3, etc…) to this column. A_I can be used if you use PRIMARY as an index.
  4. Select the table collation. This can be emptied. If empty, the table will use the database collation.
  5. Select the Storage Engine. Simply select InnoDB if you frequently perform insert, update, or delete to the table, and select MyISAM if the table is “read-only”, mean that you rarely (or even never) perform the insert, update, and delete task. Choosing the right storage engine will improve the performance of the table.
  6. Click “Save” button to save the data.

Note: at this stage, you can also change the table name by changing the text in the “Table name:” field at the top side, or add the number of columns by filling the “Add Columns” field and clicking the GO button next to the “Table name” field

Once successful, you will see the name of the table we have created on the left panel, under the name of the database where the table was created.

List of Tables in phpMyAdmin

Done, that’s all about how to create table using phpMyAdmin.

II. How to Edit Table Using phpMyAdmin

After successfully creating the new table, sometimes known later that there had been a mistake to the table or the structure of the table has been changed including change to the data type, index, etc.., which need to edit the table.

To edit table using phpMyAdmin, follow these steps:

  1. Go to the table structure. To do so, click on the database name, and then click the “structure” link of the desired table.

    How to Edit Table Using phpMyAdmin - Table Structure

    Or if the table has already been selected (the table name appears on the breadcrumbs), you can directly click on the “Structure” tab menu that exists on the top side.

    Open Table Structure via Breadcrumbs - phpMyAdmin

  2. Next, choose a column you want to edit and click on the “change” link located in the “action” section.

    Changing The Table Structure

    Or to edit more than one tables at once, click the checkbox that located to the left of the table name, or just click the “Check All” link if you want to select all, then click the “Change” button located at the bottom side.

    How to Edit Multiple Tables Using phpMyAdmin

  3. Then on the next page, change the parameters of the column, an explanation of the parameters can be seen in the previous section (creating a table), note that the parameters are slightly different, there is an option “Move Column” which will be used to shift the sequence of the columns.

    Editing Table Using phpMyAdmin - Fillin The Parameters

  4. Click Save to save the changes.

Done, that’s all about how to edit table using phpMyAdmin.

III. How to Delete Table Using phpMyAdmin

Furthermore, sometimes the existing tables are no longer needed, either due to changes in the table structure or due to other things, that make us need to remove it.

To delete table using phpMyAdmin, follow these steps:

  1. Click the database name where the tables you want to remove in.
  2. Choose the table you want to delete, then click on the “drop” link.

    How to Delete Table Using phpMyAdmin

  3. If you want to remove more than one table at once, check the checkbox button on each of table name and then click the “With Selected” dropdown menu located at the bottom and choose “Drop” option.

    How to Delete Multiple Tables Using phpMyAdmin

    A popup window will appear confirmed whether you really want to delete the table(s). Click Yes to continue.

  4. Or if you are currently work with the table (the table name appears on the Breadcrumbs) then simply click on the “Operations” tab menu. Go to “Delete data or table” section and click the link “Delete the table (DROP)”

    Deleting Table Using phpMyAdmin - Operations Menu

    A confirmation popup will appear, just click Yes to continue

Done, that’s all about how to delete table using phpMyAdmin.

 

Related Post

Leave a comment

Like Us

Social