How to create and delete databases and tables in MySQL
This page is a memo of how to do some tasks with the MySQL database engine.
Create a new database
To create a new database,
mysql> CREATE DATABASE name;
name is the name of the new database.
Select which database to use
To choose a database,
mysql> USE name;
name is the name of the database you wish to use.
Find out what databases exist
To get a list of all the databases,
mysql> SHOW DATABASES;
Find out what tables the current database has
To get a list of tables in the current database, use
mysql> SHOW TABLES;
Create a table
To make a new table in the current database which can contain a list of numbers,
mysql> CREATE TABLE name (numbers INTEGER);
name is the name of the table, and
numbers is the name of the column which contains the numbers.
To make a new table which can contain a list of numbers and words,
mysql> CREATE TABLE name (numbers INTEGER, words TEXT);
Delete a table from a database
To remove a table from a database,
mysql> DROP TABLE name;
name is the name of the table you wish to remove.
Delete a database
To delete a database,
mysql> DROP DATABASE name;
name is the name of the database you wish to remove.
Copyright © Ben Bullock 2009-2019
For comments, questions, and corrections, please email
) or use the discussion group at Google Groups