Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

MySQL Create, Drop Tables

MySQL Create, Drop Tables

You can create or delete MySQL tables as many as you want

Create MySQL Tables


CREATE TABLE tableName (columnName columnType);

Code Expanation

  • tableName: is the name of the table you want to create.

  • columnName: is the name of the columns you want to create in that table

  • columnType: is the type of there respective column.You will understand more in Column Types in next Chapter.

Example of Creating a MySQL Table


$host = 'localhost:3036';
$user = 'root';
$pass = '';
$conn = mysql_connect($host, $user, $pass);

mysql_select_db( 'Demodata' );

$sql = "CREATE TABLE student_info
          ( ".
               "student_name text(100) NOT NULL, ".
               "course text(40) NOT NULL, ".
          ); ";

$create = mysql_query( $sql );


Code Expanation

  • This will create a MySQL table name student_info in Demodata database.
  • The table has two columns named student_name and course both are having type of text
  • The Columns have length of 100 and 40 respectively and these values cannot be Null

You will learn more on Column datatype and other column values in next chapter.

Drop MySQL Tables

You can easily delete any MySQL table you want.But Be aware that you cannot recover data after dropping a table


$sql = "DROP TABLE student_info";
$delete = mysql_query( $sql );

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH