Learning Mysql databases, Mysql table creation is the most basic knowledge. The following is an example of creating a Mysql table for your reference. I hope it will help you learn how to create a Mysql table.
<! -- Create a Mysql table named world
Create three columns:
Id, which is a number.
Name, type is character
Location, which is a character
- <? Php
- ///// // Create a connection with mysql
- $ Con = mysql_connect ("localhost", "root ","");
- If (! $ Con)
- {
- Die ('could not connect: '. mysql_error ());
- }
- //// // Create a database
- If (mysql_query ("create database my_db", $ con ))
- {
- Echo "Database created ";
- }
- Else
- {
- Echo "Error creating database:". mysql_error ();
- }
- Mysql_select_db ("my_db", $ con); // select a database
- ////////// Table creation statement
- $ SQL = "CREATE TABLE world
- (
- Id int (20 ),
- Name varchar (6 ),
- Location varchar (15)
-
- )";
- Mysql_query ($ SQL, $ con); // execute the table creation statement
- //// // Insert data into the table
- Mysql_query ("insert into world (Id, Name, Location)
- VALUES ('20140901', 'ning', '1970. 100000 ')");
- // Close the connection
- Mysql_close ($ con);?>
Then add some records to it -->
MySQL connection query Overview
MySQL queries tables with matching letters
MySQL table lock status and number of opened files
View the processes of the MySQL server
How to enable MySQL slow Query