您好,登錄后才能下訂單哦!
生產系統環境:
[sky@sky9896 ~]$ cat /etc/redhat-release
CentOS release 6.8 (Final)
1. 登錄數據庫:
[sky@sky9896 ~]$ mysql –uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 151757
Server version: 5.5.49-cll-lve MySQL Community Server (GPL) by Atomicorp
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
2. 查看數據庫版本當前登錄用戶是什么
mysql> select version(); #查看數據庫版本
+----------------+
| version() |
+----------------+
| 5.5.49-cll-lve |
+----------------+
1 row in set (0.00 sec)
mysql> select user(); #查看當前登錄用戶
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.02 sec)
3.創建GBK字符集的數據庫skyboy,并查看已建庫的完整語句。
mysql> create database skyboy character set gbk collate gbk_chinese_ci;
Query OK, 1 row affected (0.03 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| a |
| back20150625ultrax |
| cacti |
| cacti20151220 |
| cacti20160104 |
| feifeicms |
| mysql |
| performance_schema |
| phpcom |
| skyboy |
| study |
| syslog |
| test |
| test1 |
| tt |
| ultrax |
+--------------------+
17 rows in set (0.04 sec)
mysql> show create database skyboy\G #查看已建庫的完整語句
*************************** 1. row ***************************
Database: skyboy
Create Database: CREATE DATABASE `skyboy` /*!40100 DEFAULT CHARACTER SET gbk */
1 row in set (0.00 sec)
4.創建用戶skyboy,使之可以管理數據庫skyboy。
mysql> grant all on skyboy.* to skyboy@'localhost' identified by '123456';
Query OK, 0 rows affected (0.09 sec)
5.查看創建的用戶skyboy擁有哪引起權限。
mysql> show grants for skyboy@'localhost'\G
***************************1.row********************
Grants for skyboy@localhost: GRANT USAGE ON *.* TO 'skyboy'@'localhost' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'
***************************2.row********************
Grants for skyboy@localhost: GRANT ALL PRIVILEGES ON `skyboy`.* TO 'skyboy'@'localhost'
2 rows in set (0.00 sec)
6.查看當前數據庫里有哪些用戶。
mysql> select user,host from mysql.user;
+-----------+-----------------+
| user | host |
+-----------+-----------------+
| cacti | % |
| cactiuser | % |
| root | % |
| cacti | * |
| root | * |
| root | 115.151.218.186 |
| cacti | 117.40.239.9 |
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| a1 | localhost |
| a2 | localhost |
| cactiuser | localhost |
| root | localhost |
| sky9896 | localhost |
| skyboy | localhost |
| | sky9896 |
| root | sky9896 |
+-----------+-----------------+
18 rows in set (0.00 sec)
7.進入skyboy數據庫
mysql> use skyboy;
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| skyboy |
+------------+
1 row in set (0.00 sec)
8.創建一innodb引擎字符集為GBK表test,字段為id和name varchar(16),查看建表結構及SQL語句。
mysql> create table test(
-> id int(4),
-> name varchar(16)
-> )ENGINE=innodb default charset=gbk;
Query OK, 0 rows affected (0.35 sec)
mysql> show tables;
+------------------+
| Tables_in_skyboy |
+------------------+
| test |
+------------------+
1 row in set (0.00 sec)
mysql> desc test; #查看表結構,方法一
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(4) | YES | | NULL | |
| name | varchar(16) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> show columns from test; #查看表結構,方法二
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(4) | YES | | NULL | |
| name | varchar(16) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> show create table test\G #查看表結構
*************************** 1. row ***************************
Table: test
Create Table: CREATE TABLE `test` (
`id` int(4) DEFAULT NULL,
`name` varchar(16) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk
1 row in set (0.00 sec)
9.插入一條數據1,skyboy
mysql> insert into test values(1,'skyboy');
Query OK, 1 row affected (0.06 sec)
mysql> select * from test;
+------+--------+
| id | name |
+------+--------+
| 1 | skyboy |
+------+--------+
1 row in set (0.00 sec)
10.批量插入數據2,堅持學MySQL,3,備考項管。要求中文不能亂碼。
mysql> insert into test values(2,'堅持學習MySQL'),(3,'參加項管考試'); #英文狀態下的標點符號
Query OK, 2 rows affected (0.07 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from test;
+------+--------------------+
| id | name |
+------+--------------------+
| 1 | skyboy |
| 2 | 堅持學習MySQL |
| 3 | 參加項管考試 |
+------+--------------------+
3 rows in set (0.00 sec)
11.查詢插入的所有記錄,查詢名字為skyboy的記錄。查詢id大于1的記錄。
mysql> select * from test;
+------+--------------------+
| id | name |
+------+--------------------+
| 1 | skyboy |
| 2 | 堅持學習MySQL |
| 3 | 參加項管考試 |
+------+--------------------+
3 rows in set (0.00 sec)
mysql> select * from test; #查詢插入的所有記錄
+------+--------------------+
| id | name |
+------+--------------------+
| 1 | skyboy |
| 2 | 堅持學習MySQL |
| 3 | 參加項管考試 |
+------+--------------------+
3 rows in set (0.00 sec)
mysql> select * from test where name='skyboy'; #查詢名字為skyboy的記錄
+------+--------+
| id | name |
+------+--------+
| 1 | skyboy |
+------+--------+
1 row in set (0.00 sec)
mysql> select * from test where id>1; #查詢id大于1的記錄
+------+--------------------+
| id | name |
+------+--------------------+
| 2 | 堅持學習MySQL |
| 3 | 參加項管考試 |
+------+--------------------+
2 rows in set (0.00 sec)
12.把數據id等于 1的名字skyboy更改為sky9890。
mysql> update test set name='sky9890' where id=1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test;
+------+--------------------+
| id | name |
+------+--------------------+
| 1 | sky9890 |
| 2 | 堅持學習MySQL |
| 3 | 參加項管考試 |
+------+--------------------+
3 rows in set (0.00 sec)
13.在字段name前插入age 字段,類型tinyint(2)。
mysql> alter table test add age tinyint(2) after id;
Query OK, 3 rows affected (0.34 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> desc test;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(4) | YES | | NULL | |
| age | tinyint(2) | YES | | NULL | |
| name | varchar(16) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
14.備份skyboy庫
root@sky9896 ~]# mysqldump -uroot -p skyboy >/opt/bak.sql
Enter password:
[root@sky9896 ~]# ll /opt/bak.sql
-rw-r--r-- 1 root root 1923 8月 13 15:38 /opt/bak.sql
[root@sky9896 ~]# cat /opt/bak.sql
-- MySQL dump 10.13 Distrib 5.5.49, for Linux (x86_64)
--
-- Host: localhost Database: skyboy
-- ------------------------------------------------------
-- Server version 5.5.49-cll-lve
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `test`
--
DROP TABLE IF EXISTS `test`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `test` (
`id` int(4) DEFAULT NULL,
`age` tinyint(2) DEFAULT NULL,
`name` varchar(16) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `test`
--
LOCK TABLES `test` WRITE;
/*!40000 ALTER TABLE `test` DISABLE KEYS */;
INSERT INTO `test` VALUES (1,NULL,'sky9890'),(2,NULL,'堅持學習MySQL'),(3,NULL,'參加項管考試');
/*!40000 ALTER TABLE `test` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2016-08-13 15:38:31
15.刪除表中的所有數據,并查看。
mysql> delete from test; #邏輯刪除表中的數據,一列一列的刪除表中數據,速度慢
Query OK, 3 rows affected (0.07 sec)
mysql> truncate table test; #物理刪除表中的數據,一次性全部都給清空,速度很快
Query OK, 0 rows affected (0.07 sec)
mysql> select * from test; #查看結果
Empty set (0.00 sec)
mysql> show tables;
+------------------+
| Tables_in_skyboy |
+------------------+
| test |
+------------------+
1 row in set (0.00 sec)
mysql> drop table test;
Query OK, 0 rows affected (0.07 sec)
mysql> show tables;
Empty set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| a |
| back20150625ultrax |
| cacti |
| cacti20151220 |
| cacti20160104 |
| feifeicms |
| mysql |
| performance_schema |
| phpcom |
| skyboy |
| study |
| syslog |
| test |
| test1 |
| tt |
| ultrax |
+--------------------+
17 rows in set (0.00 sec)
mysql> drop database skyboy;
Query OK, 0 rows affected (0.04 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| a |
| back20150625ultrax |
| cacti |
| cacti20151220 |
| cacti20160104 |
| feifeicms |
| mysql |
| performance_schema |
| phpcom |
| study |
| syslog |
| test |
| test1 |
| tt |
| ultrax |
+--------------------+
16 rows in set (0.00 sec)
17.Linux命令行恢復以上刪除的數據
恢復的時候,要先建一個skyboy空數據,然后在恢復。
[root@sky9896 ~]# mysql -uroot -p skyboy</opt/bak.sql
Enter password:
mysql> use skyboy;
Database changed
mysql> show tables;
+------------------+
| Tables_in_skyboy |
+------------------+
| test |
+------------------+
1 row in set (0.00 sec)
mysql> select * from test;
+------+------+--------------------+
| id | age | name |
+------+------+--------------------+
| 1 | NULL | sky9890 |
| 2 | NULL | 堅持學習MySQL |
| 3 | NULL | 參加項管考試 |
+------+------+--------------------+
3 rows in set (0.00 sec)
18.把GBK字符集修改為UTF8。
mysql> 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/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> set global character_set_database=gbk;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@sky9896 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 152566
Server version: 5.5.49-cll-lve MySQL Community Server (GPL) by Atomicorp
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like 'character_set%'; #數據庫服務的字符集
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
19.修改mysql密碼
mysql> update mysql.user set password=PASSWORD('skyboy') where user='root'
and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
20.MySQL內中文數據亂碼的原理及如何防止亂碼?(可選)。
#客戶端軟件字符集要用utf8
[root@sky9896 ~]# cat /etc/sysconfig/i18n #修改字符配置文件
LANG="zh_CN.UTF-8"
21.在把id 列設置為主鍵,在Name字段上創建普通索引。
mysql> alter table skyboy.test add primary key(id);
Query OK, 3 rows affected (0.32 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> desc skyboy.test;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(4) | NO | PRI | 0 | |
| age | tinyint(2) | YES | | NULL | |
| name | varchar(16) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> create index index_name on skyboy.test(name);
Query OK, 0 rows affected (0.23 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc skyboy.test;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(4) | NO | PRI | 0 | |
| age | tinyint(2) | YES | | NULL | |
| name | varchar(16) | YES | MUL | NULL | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
22.在字段name后插入手機號字段(shouji),類型char(11)。
mysql> alter table skyboy.test add shouji char(11) after name;
Query OK, 3 rows affected (0.23 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> desc skyboy.test;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(4) | NO | PRI | 0 | |
| age | tinyint(2) | YES | | NULL | |
| name | varchar(16) | YES | MUL | NULL | |
| shouji | char(11) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
23.所有字段上插入 2條記錄(自行設定數據)
mysql> insert into test values(4,21,'sky','20160813'),(5,98,'skyboy','20160810');
Query OK, 2 rows affected (0.04 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from test;
+----+------+-----------+----------+
| id | age | name | shouji |
+----+------+-----------+----------+
| 1 | NULL | sky9890 | NULL |
| 2 | NULL | ????MySQL | NULL |
| 3 | NULL | ?????? | NULL |
| 4 | 21 | sky | 20160813 |
| 5 | 98 | skyboy | 20160810 |
+----+------+-----------+----------+
5 rows in set (0.00 sec)
以上顯示了亂碼,解決方式如下:
[root@sky9896 ~]# vi /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
遠程退出
重新登錄才能生效
mysql> use skyboy;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from test;
+----+------+--------------------+----------+
| id | age | name | shouji |
+----+------+--------------------+----------+
| 1 | NULL | sky9890 | NULL |
| 2 | NULL | 堅持學習MySQL | NULL |
| 3 | NULL | 參加項管考試 | NULL |
| 4 | 21 | sky | 20160813 |
| 5 | 98 | skyboy | 20160810 |
+----+------+--------------------+----------+
5 rows in set (0.00 sec)
24.在手機字段上對前 8個字符創建普通索引。
mysql> alter table test add index index_shouji(shouji(8));
Query OK, 0 rows affected (0.17 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc test;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(4) | NO | PRI | 0 | |
| age | tinyint(2) | YES | | NULL | |
| name | varchar(16) | YES | MUL | NULL | |
| shouji | char(11) | YES | MUL | NULL | |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
25.查看創建的索引及索引類型等信息。
mysql> show index from skyboy.test\G
*************************** 1. row ***************************
Table: test
Non_unique: 0
Key_name: PRIMARY
Seq_in_index: 1
Column_name: id
Collation: A
Cardinality: 5
Sub_part: NULL
Packed: NULL
Null:
Index_type: BTREE
Comment:
Index_comment:
*************************** 2. row ***************************
Table: test
Non_unique: 1
Key_name: index_name
Seq_in_index: 1
Column_name: name
Collation: A
Cardinality: 5
Sub_part: NULL
Packed: NULL
Null: YES
Index_type: BTREE
Comment:
Index_comment:
*************************** 3. row ***************************
Table: test
Non_unique: 1
Key_name: index_shouji
Seq_in_index: 1
Column_name: shouji
Collation: A
Cardinality: 5
Sub_part: 8
Packed: NULL
Null: YES
Index_type: BTREE
Comment:
Index_comment:
3 rows in set (0.01 sec)
26.刪除Name,shouji列的索引。
mysql> alter table test drop index index_name;
Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> drop index index_shouji on test;
Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show index from test\G;
*************************** 1. row ***************************
Table: test
Non_unique: 0
Key_name: PRIMARY
Seq_in_index: 1
Column_name: id
Collation: A
Cardinality: 5
Sub_part: NULL
Packed: NULL
Null:
Index_type: BTREE
Comment:
Index_comment:
1 row in set (0.00 sec)
27.對Name列的前6 個字符以及手機列的前8個字符組建聯
合索引。
mysql> alter table test add index index_name_shouji(name(6),shouji(8));
Query OK, 0 rows affected (0.15 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show index from test\G
*************************** 1. row ***************************
Table: test
Non_unique: 0
Key_name: PRIMARY
Seq_in_index: 1
Column_name: id
Collation: A
Cardinality: 5
Sub_part: NULL
Packed: NULL
Null:
Index_type: BTREE
Comment:
Index_comment:
*************************** 2. row ***************************
Table: test
Non_unique: 1
Key_name: index_name_shouji
Seq_in_index: 1
Column_name: name
Collation: A
Cardinality: 5
Sub_part: 6
Packed: NULL
Null: YES
Index_type: BTREE
Comment:
Index_comment:
*************************** 3. row ***************************
Table: test
Non_unique: 1
Key_name: index_name_shouji
Seq_in_index: 2
Column_name: shouji
Collation: A
Cardinality: 5
Sub_part: 8
Packed: NULL
Null: YES
Index_type: BTREE
Comment:
Index_comment:
3 rows in set (0.00 sec)
28.查詢手機號以159開頭的,名字為skybboy的記錄。
mysql> select * from test where name='skyboy' and shouji like '159%';
+----+------+--------+-------------+
| id | age | name | shouji |
+----+------+--------+-------------+
| 5 | 98 | skyboy | 15907999899 |
+----+------+--------+-------------+
1 row in set (0.00 sec)
29.查詢上述語句的執行計劃(是否使用聯合索引等)。
mysql> explain select * from test where name='skyboy' and shouji like '159%';
+----+-------------+-------+-------+-------------------+-------------------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+-------------------+-------------------+---------+------+------+-------------+
| 1 | SIMPLE | test | range | index_name_shouji | index_name_shouji | 32 | NULL | 1 | Using where |
+----+-------------+-------+-------+-------------------+-------------------+---------+------+------+-------------+
1 row in set (0.00 sec)
mysql> explain select * from test where name='skyboy' and shouji like '159%'\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test
type: range
possible_keys: index_name_shouji
key: index_name_shouji
key_len: 32
ref: NULL
rows: 1
Extra: Using where
1 row in set (0.00 sec)
30.把test表的引擎改成MyISAM。
MySQL 數據庫 5.1 版本以前默認的引擎是 MyISAM
MySQL 數據庫 5.5 版本以后默認的引擎都是 InnoDB
mysql> show create table test\G #查看test表引擎
*************************** 1. row ***************************
Table: test
Create Table: CREATE TABLE `test` (
`id` int(4) NOT NULL DEFAULT '0',
`age` tinyint(2) DEFAULT NULL,
`name` varchar(16) DEFAULT NULL,
`shouji` char(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_name_shouji` (`name`(6),`shouji`(8))
) ENGINE=InnoDB DEFAULT CHARSET=gbk
1 row in set (0.00 sec)
mysql> alter table test ENGINE=MyISAM; #修改默認引擎
Query OK, 5 rows affected (0.14 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> show create table test\G
*************************** 1. row ***************************
Table: test
Create Table: CREATE TABLE `test` (
`id` int(4) NOT NULL DEFAULT '0',
`age` tinyint(2) DEFAULT NULL,
`name` varchar(16) DEFAULT NULL,
`shouji` char(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_name_shouji` (`name`(6),`shouji`(8))
) ENGINE=MyISAM DEFAULT CHARSET=gbk
1 row in set (0.00 sec)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。