MySQL數(shù)據(jù)庫操作常用命令小結(jié)
創(chuàng)建數(shù)據(jù)庫
最簡單的方式:
CREATE DATABASE my_db;
或者是:
CREATE DATABASE IF NOT EXISTS my_db;
創(chuàng)建utf8編碼的數(shù)據(jù)庫:
CREATE DATABASE IF NOT EXISTS my_db default character set utf8 COLLATE utf8_general_ci;
那么在這個數(shù)據(jù)庫下創(chuàng)建的所有數(shù)據(jù)表的默認字符集都會是utf8了,注意后面這句話 "COLLATE utf8_general_ci",大致意思是在排序時根據(jù)utf8變碼格式來排序。
查看數(shù)據(jù)庫列表:
show databases;
使用數(shù)據(jù)庫:
use my_db;
查看數(shù)據(jù)庫默認編碼:
show variables like 'character_set_%'
+--------------------------+-------------------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.5.28-linux2.6-i686/share/charsets/ |
+--------------------------+-------------------------------------------------------+
可以看到character_set_database是lantin1.
修改數(shù)據(jù)庫編碼:
alter database my_db character set latin1;
刪除數(shù)據(jù)庫:
drop database my_db;
或者是:
drop database IF EXISTS my_db;
- MySQL數(shù)據(jù)庫備份和還原的常用命令小結(jié)
- MySQL操作數(shù)據(jù)庫和表的常用命令新手教程
- MySQL數(shù)據(jù)庫維護中監(jiān)控所用到的常用命令
- MySQL 數(shù)據(jù)庫常用命令 簡單超級實用版
- MySQL數(shù)據(jù)庫管理常用命令小結(jié)
- MySQL常用命令 MySQL處理數(shù)據(jù)庫和表的命令
- MYSQL 數(shù)據(jù)庫導入導出命令
- Mysql數(shù)據(jù)庫的一些命令
- MySQL優(yōu)化全攻略-相關(guān)數(shù)據(jù)庫命令
- mysqldump命令導入導出數(shù)據(jù)庫方法與實例匯總
- MySQL命令行導出導入數(shù)據(jù)庫實例詳解
- MySQL數(shù)據(jù)庫基礎入門之常用命令小結(jié)
相關(guān)文章
MySQL建立數(shù)據(jù)庫時字符集與排序規(guī)則的選擇詳解
當數(shù)據(jù)庫需要適應不同的語言就需要有不同的字符集,下面這篇文章主要給大家介紹了關(guān)于MySQL建立數(shù)據(jù)庫時字符集與排序規(guī)則的選擇的相關(guān)資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-06-06