Hackernoon logo[MySQL] Note: Database CURD by@peterchang_82818

[MySQL] Note: Database CURD

MySQL databases, it consists of tables, table is made up of columns (or fields) and rows (records). They are a spider net, complicated but well organised.

This Note includes 4 most comment used command, it is all I need in operating database:

  1. Create and Delete
  2. Show All Databases
  3. Set Default Database
  4. Show Current Database

1 — Create and Delete

mysql> CREATE DATABASE southwind;
Query OK, 1 row affected (0.03 sec)

mysql> DROP DATABASE southwind;
Query OK, 0 rows affected (0.11 sec)

mysql> CREATE DATABASE IF NOT EXISTS southwind;
Query OK, 1 row affected (0.01 sec)

mysql> DROP DATABASE IF EXISTS southwind;
Query OK, 0 rows affected (0.00 sec)

2 — Show All Database

mysql> SHOW DATABASES;

3 — Set Default Database

mysql> USE southwind;

4— Show Current Database

mysql> SELECT DATABASE();

You may also like

Reference:

https://www.cyberciti.biz/faq/mysql-list-databases/

https://www.ntu.edu.sg/home/ehchua/programming/sql/MySQL_Beginner.html

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.