Welcome to MySQL Tutorial for Beginners part 4. Today we will create a database. And Create some Data.We are going to start using MySQL commands. Before we start we need to have some sort of Data.We are going to create some sample data. By now you should have required Software and Utilities for MySQL Installed on your PC. If not check earlier MySQL Tutorial for Beginners part 3.

MySQL Tutorial for beginners
MySQL Tutorial for beginners

Start MySQL Community Server,Toad or Sequel Pro on you computer. Then we are going to create a new connection to database server. Follow the steps below:

Connecting Toad to MySQL community server:
For Toad go to File > New > Connection. Then you will see a new connection window like the picture below.
Toad New Connection

From the Connection Type select TCP. You can select connection type such as TCP, SSL, SSH, HTTP Tunnel . We will use TCP connection.

Here are the information to make new connection using Toad for MySQL.
Connection Type: TCP
Host :  localhost
User :  root
Password: Type in your Password
Database: test

If you want to save the connection fill out the details at the bottom of the window.

Name:  Anything you want (type IN)
Category:  Select your Category

Then  click the Save / Connect button. This new connection will be listed in the Connection Manager. After connecting go to Tools > Editor . We will write our Command in this editor.

If you are using MAC OS then you can use Sequel Pro as a alternative to Toad for MySQL. After Starting Sequel Pro you will see a window like the picture below:
Sequel Pro
Here are the information to make new connection using sequel pro:

Name:  Type in Any Name
MySQL Host:  localhost
Username: root
password: Type in your password
Database: test
Port: If any

Then Hit connect Button. Then click on Query to open the editor. Now we know where we going to spend our time. We are ready for Writing some MySQL Query. Here are some Rules to follow while writing MySQL Statements:
1.Reserved words should be uppercase.
2.A void using names like “CREATE”, “SHORT” and reserved words.
3. Any Object Name cannot start with space or End with Space.
4. If we want to create a table name Employee table and we write the name like : employeetable this word is pretty hard to read. But if we write emmployee_table then we can easily recognize this table.
Here we go…

CREATE DATABASE Statement In MySQL : We are going to Create a New Database Using the Editor. How to create Database in MySQL ? Just Type in

CREATE DATABASE  Database Name;

For Our Tutorial We are going to use this :

CREATE DATABASE  student;

Then Select all and Click on Execute Script On Toad This will create a database named student

Practice
Now Create a new Connection in Toad to Connect the Database named student.

After Connecting to the new Database are going to create a Table In MySQL Database.

How to create a Table In MySQL Database : We need to use CREATE TABLE statement to create a table in the Database student.

To create table we need to type in

CREATE TABLE table_name (
       column_1 What type of data,
       column_2 What type of data,
       column_3 What type of data,...)

For Our Tutorial We are going to create a table name studenttb  which have student_id, FirstName and LastName colums Here is a the query :

CREATE TABLE studenttb(
  student_id int(11) NOT NULL AUTO_INCREMENT,
  FirstName  varchar(100) DEFAULT NULL,
  LastName varchar(100) DEFAULT NULL,
  PRIMARY KEY (`student_id`)
)

By Garnel

I like to write about Tips And Tutorials related topics and I blog about my personal interests. I am trying to learn the ways to Promote Blog. Sharing my limited knowledge with the world. Blogging about Tips, Tutorials, and Tweaks for Computers, Internet, Operating System, Windows Xp, Windows Vista, Office Applications, Gadgets, Science, and Technology. And Having Fun..

One thought on “MySql Tutorial for Beginners Part 4 – CREATE Statement MySql”

Leave a Reply

Your email address will not be published. Required fields are marked *

three − two =