Create Table in MySQL using PHPMyAdmin

In order to create a new table in MySQL database follows the steps given below:
Step 1: Launch PHPMyAdmin from the taskbar as shown below:
Step 2: Select name of the database in which you want to create table.
Step 3: Enter name of new table and specify how many fields you want to add in the table as shown below.

After Specifying table name and number of fields Click on GO button to create new table.
Step 4: As you click on GO button it will asks you to define fields for your table by specifying field name and their data types as shown below: FieldType
After Specifying Field Name and DataType click on Save Button.
Step 5: As you click on save button it will create new table with specified field and display the statement to create new table as shown below:
Step 6: After creating table if you want to define primary key in the table then select the field name from the list of fields as shown below and click on (Primary Key) button.
Step 7: As you click on * (Primary Key) button it will display confirmation message as shown below:
Step 8: Click on OK button if you want to assign primary key to selected field. As you click on OK button it will assign primary key to the selected field.
After creating table you can perform following operations on table as shown below:

* Browse Browse records from the table.
*  Edit or Change Edit or change the field specification.
 Delete Delete selected field from table.
* Primary key Assign primary key to selected field.
* Unique Key Define unique key for selected field.
 Index Define index for selected field.

After creating table, if you want to add new fields to the table then you can do so by specifying number of fields to be added at the beginning, ending or after selected field as shown below:



Create Table in MySQL using PHP Script

In order to create new database table write following PHP script:

// Establish Connection with MYSQL
$con = mysql_connect("localhost","root");
// Select Database
mysql_select_db ("DBDEMO", $con);
// specify the query to create Table
$sql = "Create Table Customer_Master(CustomerCode int Primary Key, CustomerName varchar(50), City varchar(50))";
// execute query
mysql_query ($sql,$con);
// Close The Connection
mysql_close ($con);
echo "Table Created Successfully";

Download Projects

Download Programs