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;where
name
is the name of the new database.
Select which database to use
To choose a database,mysql> USE name;where
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, usemysql> 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);Here
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;where
name
is the name of the table you wish to remove.
Delete a database
To delete a database,mysql> DROP DATABASE name;where
name
is the name of the database you wish to remove.
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com).
/
Privacy /
Disclaimer