珠海网站建设平台,外贸软件哪个好,外贸网站主机选择,网页设计与网站开发MyISAM和InnoDB的区别
MyISAM和InnoDB的区别
Mysql在V5.1之前默认存储引擎是MyISAM#xff1b;在此之后默认存储引擎是InnoDB
MyISAM不支持事务#xff0c;而InnoDB支持。InnoDB的AUTOCOMMIT默认是打开的#xff0c;即每条SQL语句会默认被封装成一个事务#xff0c;自动提…MyISAM和InnoDB的区别
MyISAM和InnoDB的区别
Mysql在V5.1之前默认存储引擎是MyISAM在此之后默认存储引擎是InnoDB
MyISAM不支持事务而InnoDB支持。InnoDB的AUTOCOMMIT默认是打开的即每条SQL语句会默认被封装成一个事务自动提交这样会影响速度所以最好是把多条SQL语句显示放在begin和commit之间组成一个事务去提交。
InnoDB支持数据行锁定MyISAM不支持行锁定只支持锁定整个表。即 MyISAM同一个表上的读锁和写锁是互斥的MyISAM并发读写时如果等待队列中既有读请求又有写请求默认写请求的优先级高即使读请求先到所以 MyISAM不适合于有大量查询和修改并存的情况那样查询进程会长时间阻塞。因为MyISAM是锁表所以某项读操作比较耗时会使其他写进程饿死。
InnoDB支持外键MyISAM不支持。
Innodb能存储64TBMyISAM能存储256TB
InnoDB不支持全文索引而MyISAM支持。全文索引是指对char、 varchar和text中的每个词停用词除外建立倒排序索引。MyISAM的全文索引其实没啥用因为它不支持中文分词必须由使用者分词后加入空格再写到数据表里而且少于4个汉字的词会和停用词一样被忽略掉。书的目录
MyISAM支持GIS数据InnoDB不支持。即MyISAM支持以下空间数据对象Point,Line,Polygon,Surface等。
没有where的count(*)使用MyISAM要比InnoDB快得多。因为MyISAM内置了一个计数器count(*)时它直接从计数器中读而InnoDB必须扫描全表。
数据库
神器 edit 在edit里边编辑wq保存出来敲一个分号
\e
#创建库
create database company default charset utf8
#查看库
show databases;
show create databse company
#进入库
use company;
#创建表
create table t1(id int(2),name char(20),age int);字段 类型 字段 类型(长度)字段 类型 (
#查看表
(show desc(describe) select)
#查看表名称
show tables;
desc t1;(表的详细字段信息)
#查看表创建过程
show create table t1;
#当表特别长的时候则把表向左旋转90度可以更清楚看到
show create table t1\G第一列显示字段名称第二列显示记录
#查看表结构
desc t1
#查看表记录
select * from 表名
select 字段字段 from 表名
#查看表状态
show table status like 表名 ;
#修改表
alter) (add delect change)
#修改表名
rename table 原表名 to 新表名;
rename table t11 to t9; alter table t9 rename to t1;
#添加字段
alter table 表名 add 字段 修饰符;
alter table t1 add gender char(20);
alter table t1 add grade char(20) after id;
alter table t1 add zhuanye char(20) first;
#删除字段
alter table 表名 drop 字段;
#修改字段
alter table 表名 change 旧字段 新字段 修饰符; change修改字段名称类型约束顺序
alter table 表名 modify 字段 属性 修饰符 modify 不能修改字段名称
alter table t1 change zhuanye major varchar(20) after gender;
alter table t1 modify major varchar(20) after age; #修改记录
(inster update delete where)
#添加记录
insert into 表名 values (),(),(),();
insert into 表名(字段字段字段) values (),(),();
insert into t1 values(1,2,yingge,18,12,male);
insert into t1(name,grade) values (wing,1);
insert into t1(name,grade) values (newrain,2),(houzi,2);
insert into t1 set namejianjian,grade1;#修改记录更新
update 表名 set 字段 where 主键 ;
update t1 set grade4 where nameyingge;
#删除记录
delete from 表名 where 主键字段 ;
delete from 表名;
delete from t1 where id5; #删除表
drop table 表名
drop table t1;
#删除库
drop databse 库名
drop database company; #各种查询
select id,name from employee5 where id5;
select id,dep_id,id*dep_id from company.employee5 where id5;
select id*dep_id as id and dep_ids sum from company.employee5 where id5;查看支持的存储引擎
show engines;
#当前默认的存储引擎
show variables like %storage_engine%;
#查看Mysql服务器上的版本
select version();
#创建时候指定引擎
create table t1(id int,manager char(10)) engine innodb;
创建并管理基本表
#登录数据库
mysql -uroot -p123
#查询数据库
show databases;
#创建数据库
create database newrain default charser utf8;
#刷新数据库及表的列表内容(常用于授权之后)
flush privileges;
#删除数据库
drop database newrain;
#使用数据库
use mysql;
#查看库中的表
show tables;
#查询表中的内容,“\G”为标准化输出,不加会乱码
select * from mysql.user\G;
#根据条件查询表中的内容
select User,Host,authentication_string from user;
#更新表中的内容
update user set authentication_stringpassword((Baidu..1229)) where userroot;远程登陆
grant all on *.* to remote% identified by Sxw123456;
#授权所有的库和表使用用户remote所有地址% 密码Sxw123456
flush privileges;
#刷新授权表[rootmysql ~]# mysql -uremote -pSxw123456 -h10.12.155.20