One of the two methods used to create a table in a database
1. PHPMyAdmin, HeidiSQL, MySQL Workbech etc software to write SQL statements (these softwares have the option to write SQL)
2. With the above software, you can create a database with just a click, from inserting, deleting, updating, etc.
** Everything can be done in the database by writing a statement in CLI or command line, but number 2 is used more.
Below is a first look at how to create a database using PHPMyAdmin’s SQL tab (i.e. using method 1)
The table making statement is as follows
CREATE TABLE table_name (Enter the name of the table you want to create instead of table_name.) Example: Click on the database you created as designer (see left) and enter the following command by clicking on the SQL tab.
Now click on the GO button. A table called diameter test will be created under the designer database.
Explanation of the code above
The first line says create a table called test. The second line says I want a column called id which will be INT (10) which is a whole number (id is a whole number like someone 1, someone 20 230) and more than 10 There will be no number and then there is NOT NULL which means this column cannot be left blank.
This table is made in the 2nd method
Go to localhost / phpmyadmin and click on “designer” database.
After clicking on the “Go” button on the right, a form / window will appear to correct the attributes of the 6 fields. Here, the following or by typing / selecting the attributes as per your need and clicking on the “Save” button, the table is created.
The form is too long, the full image is not given here. Scroll down a little to the right with the scroller below, checkmark for “A_I” (Auto Increment) for “id” field and select “Primary” from “Index”. Diameter now ” The id “field will automatically increase the serial number when the data is inserted and this field has become the primary key.
** There are many other fields in which you don’t have to pay anything now just for “id” and as much as there is in the picture. Most of the time the database will be designed with this much, but we will discuss the others later.
SQL Insert Statement :
I will insert the data in the table that I created in the previous tutorial. The previous tutorial discusses how we can do database manipulation (edit, delete, insert etc.). However, here is how to insert data using PHPMyAdmin.
With SQL you can insert one or more rows in the table. You can even insert a row with data (go to the SQL tab of PHPMyAdmin, type the following query and click Go). Such as:
There are several methods of inserting data but what I have shown is that it is useful when there is no value for each field. (id, first_name, last_name are all one field)
If each field has a value, the data is inserted as follows
If you want, you can just insert data in a specific column
If you want to have another method, you can insert data in a specific column in this way.
This will leave other fields blank or default value.
GUI or click data insert (with PHPMyAdmin)
This is usually used to enter data. For this, click on the “test” table and click on the “Insert” tab at the top right. The data entry form or window will appear as below. Now enter the required data from here.
Finally press the “Go” button and the diameter data will be inserted. If there is no data for a field, leave it blank. The names of the fields do not appear on the left side of the picture, the names are in a few places above, it is clear which field’s name is which. There is no need to enter anything in the “id” field because the field you saw when creating the table is given Auto Increment so when inserting this row it will automatically enter its corresponding serial number.