MySQL Tutorials - Herong's Tutorial Examples - Version 4.11, by Dr. Herong Yang

Creating First Table in MySQL

This section provides a tutorial example on how to verify a new installation of 4.0.18 by creating a new test table and insert some data to the table.

In the previous section, we learned how to start and shutdown MySQL server. Now let's see how we can use MySQL client interface to create a table and run queries. First start the MySQL server in one command window, then run the start the MySQL client interface in another command window, and run the following MySQL client commands:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.18-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
| Database |
| mysql    |
| test     |
2 rows in set (0.06 sec)

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table hello (message varchar(80));
Query OK, 0 rows affected (0.58 sec)

mysql> insert into hello (message) values ('Hello world!');
Query OK, 1 row affected (0.38 sec)

mysql> select * from hello;
| message      |
| Hello world! |
1 row in set (0.04 sec)

mysql> drop table hello;
Query OK, 0 rows affected (0.34 sec)

mysql> quit;

Table of Contents

 About This Book

 Introduction of SQL

MySQL 4.0 Introduction and Installation

 MySQL 4.0 Introduction

 Installing MySQL 4.0.18

Creating First Table in MySQL

 Installing MySQL 5.5.15

 Installing MySQL 5.0.2 (Alpha)

 Introduction of MySQL 5.0 Programs

 Perl Programs and MySQL Servers

 PHP Programs and MySQL Servers

 Java Programs and MySQL Servers

 Datatypes and Data Literals

 Operations and Expressions

 Character Strings and Bit Strings

 Commonly Used Functions

 Table Column Types for Different Types of Values

 Using DDL to Create Tables and Indexes

 Using DML to Insert, Update and Delete Records

 Using SELECT to Query Database

 Transaction Management and Isolation Levels


 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures


 Printable Copy - PDF Version

Creating First Table in MySQL - Updated in 2012, by Dr. Herong Yang