Mysql笔记--常用命令
来源:互联网 发布:qq java版 编辑:程序博客网 时间:2024/05/30 23:47
查看建表语句
show create table tableName;
eg:
mysql> show create table demo;+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Table | Create Table |+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| demo | CREATE TABLE `demo` ( `uid` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `uname` varchar(500) DEFAULT NULL, `email` varchar(500) DEFAULT NULL, `createTime` datetime DEFAULT NULL, PRIMARY KEY (`uid`)) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 |+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)
可以看到该表使用的数据引擎事 MyISAM (该引擎不支持事务)
查看可使用的数据引擎
show engines;
eg:
mysql> show engines;+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+| Engine | Support | Comment | Transactions | XA | Savepoints |+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+| MyISAM | YES | MyISAM storage engine | NO | NO | NO || CSV | YES | CSV storage engine | NO | NO | NO || MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO || BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO || MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO || FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL || ARCHIVE | YES | Archive storage engine | NO | NO | NO || PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO || InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+9 rows in set (0.00 sec)
可以看到只有InnoDB引擎才支持事务
修改表的数据引擎
alter table tableName engine=innodb;
eg:
mysql> alter table demo engine=innodb;Query OK, 1 row affected (0.58 sec)Records: 1 Duplicates: 0 Warnings: 0mysql> show create table demo;+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Table | Create Table |+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| demo | CREATE TABLE `demo` ( `uid` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `uname` varchar(500) DEFAULT NULL, `email` varchar(500) DEFAULT NULL, `createTime` datetime DEFAULT NULL, PRIMARY KEY (`uid`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 |+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)
修改默认的存储引擎
修改my.cnf文件,在[mysqld]下加入:
default-storage-engine=INNODB
修改默认的字符集
修改my.cnf文件,在[mysqld]下加入:
# charsetdefault-character-set=utf8default-collation=utf8_general_cicharacter-set-server=utf8collation-server=utf8_general_ciinit-connect='SET NAMES utf8'
0 0
- Mysql自己常用命令笔记
- mysql常用命令 - 笔记
- Mysql笔记--常用命令
- mysql笔记2 常用命令
- linux学习笔记-----mysql常用命令。
- MySQL学习笔记----MYSQL常用命令.txt
- MySQL常用命令
- MySql常用命令
- MySQL常用命令
- mysql常用命令
- mysql常用命令
- mysql常用命令
- Mysql常用命令
- MySQL常用命令
- mysql 常用命令
- MySQL常用命令
- mysql常用命令
- MySql常用命令
- NFV的技术发展现状和未来展望
- 函数声明和函数定义中的默认参数浅析
- IOS网络编程:HTTP
- Chapter5 ASP.NET Web Server Controls
- 在系统导航栏 按钮 水平移动
- Mysql笔记--常用命令
- 博客迁移通知
- Android 适配器之ViewHoder最新写法
- mysql 触发器学习
- Exception in thread "main" org.hibernate.HibernateException: 'hibernate.dialect' must be set when no
- MapGIS 存储服务错误
- 设计模式---装饰模式(Decorator)
- 外文收录
- Linux tty串口测试程序