1.插入语句:
create table test(
id int(4) not null auto_increment,
name char(20) not null,
primary key(id)
);
insert into test (id,name) values(1,'oldboy')
select *from test;
insert into test(name) values('oldgirl')
insert into test values(4,'zuma'),(5,'kaka');
2.备份: mysqldump -uroot -poldboy124 -B oldboy >/opt/oldboy_bak.sql(逻辑备份,就是已sql语句的形式导出数据)
恢复:mysql -uroot -poldboy124 oldboy< /opt/oldboy_bak.sql
3.查询语句:
select *from test limit 3;
字符类型的查询要带引号: select *from test where name='oldboy';
4.查询语句的执行计划:explain,如下,快了整整5倍
创建索引:create index index_name on test(name);
5.删除语句:truncate table xx
truncate table xx和delete from xx的区别:
1)truncate 更快,相当于直接清除物理文件
2)delete 是逻辑清除,按行删除
6. 修改表名:rename table oldboy to oldboy1
7.mysql字符集的问题: