LCB
LCB

Reputation: 1050

What is the difference between using default charset and using default character set in MySQL while creating database

I tried using these two SQL statements to create a database:

CREATE DATABASE IF NOT EXISTS `dbname` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

and

CREATE DATABASE IF NOT EXISTS `dbname` DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

Both of these SQLs got the same result:

mysql> show create database `dbname`;
+----------------------+--------------------------------------------------------+
| Database | Create Database                                                    |
+----------------------+--------------------------------------------------------+
| dbname   | CREATE DATABASE `dbname` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------------------+--------------------------------------------------------+

But, there isn't an option named CHARSET for creating database in MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/create-database.html, I want to know the differences between these two statements.

Upvotes: 0

Views: 352

Answers (1)

FanoFN
FanoFN

Reputation: 7124

I'm trying to find any official documentation about CHARSET too but all of the search result return link to CHARACTER SET. What I do find is this MariaDB documentation which have a CREATE TABLE query using CHARSET. So, I'm guessing CHARSET is a valid synonym to CHARACTER SET.

FYI: I notice that MySQL have a lot of similar functions but slightly - to moderately different name such as CURRENT_DATE and CURDATE(). Most of these functions have almost identical name only differs slightly in spelling. However, there are two functions that I know in particular have totally different names and noticeable difference in length but perform exactly the same operation. These functions are CURRENT_TIMESTAMP and NOW(). Here is a demo.

Upvotes: 1

Related Questions