(1)创建数据库
[sql] view plaincopy
mysql> CREATE DATABASE my_db1;
Query OK, 1 row affected (0.00 sec)
(2)因为my_db1已经存在,再次创建会报错
[sql] view plaincopy
mysql> CREATE DATABASE my_db1;
ERROR 1007 (HY000): Can‘t create database ‘my_db1‘; database exists
(4)加上IF NOT EXISTS就算数据库已经存在,把原来的覆盖掉了
[sql] view plaincopy
mysql> CREATE DATABASE IF NOT EXISTS my_db1;
Query OK, 1 row affected, 1 warning (0.00 sec)
二、创建数据库包含字符集和排序规则
(1)查看mysql字符集
[sql] view plaincopy
mysql> SHOW CHARACTER SET;
+----------+-----------------------------+---------------------+--------+
| Charset | Description | Default collation | Maxlen |
+----------+-----------------------------+---------------------+--------+
| big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 |
| dec8 | DEC West European | dec8_swedish_ci | 1 |
| cp850 | DOS West European | cp850_general_ci | 1 |
| hp8 | HP West European | hp8_english_ci | 1 |
| koi8r | KOI8-R Relcom Russian | koi8r_general_ci | 1 |
| latin1 | cp1252 West European | latin1_swedish_ci | 1 |
.......
(2)查看mysql排序规则
[sql] view plaincopy
mysql> SHOW COLLATION;
+--------------------------+----------+-----+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+--------------------------+----------+-----+---------+----------+---------+
| big5_chinese_ci | big5 | 1 | Yes | Yes | 1 |
| big5_bin | big5 | 84 | | Yes | 1 |
| dec8_swedish_ci | dec8 | 3 | Yes | Yes | 1 |
| dec8_bin | dec8 | 69 | | Yes | 1 |
| cp850_general_ci | cp850 | 4 | Yes | Yes | 1 |
| cp850_bin | cp850 | 80 | | Yes | 1 |
| hp8_english_ci | hp8 | 6 | Yes | Yes | 1 |
.................
(3)创建数据库包括字符集和排序规则
[sql] view plaincopy
mysql> CREATE DATABASE IF NOT EXISTS hdu CHARACTER SET ‘gbk‘ COLLATE ‘gbk_chinese_ci‘;
Query OK, 1 row affected (0.00 sec)
三、删除数据库
[sql] view plaincopy
mysql> DROP DATABASE my_db1;
Query OK, 0 rows affected (0.00 sec)
mysql数据库创建、删除数据库
标签:views l数据库 pop drop star 删除数据库 href font har
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:https://www.cnblogs.com/lxwphp/p/8336711.html