mysql的一些笔记
来源:互联网 发布:怎么把手机照片导入mac 编辑:程序博客网 时间:2024/06/03 20:04
创建数据库:create database if not exists firefly default charset utf8 collate utf8_general_ci;
(CREATE DATABASE IF NOT EXISTS FIREFLY DEFAULT CHARSET utf8 COLLATE utf8_general_ci;)创建的时候都是小写的firefly
删除数据库:drop database firefly;(这个一定要是小写)
选择数据库:use firefly;
创建数据表:create table if not exists `testone`(`id` int unsigned auto_increment,
`contents` text not null,
primary key(`id`)
)engine=myisam default charset=utf8;
CREATE TABLE IF NOT EXISTS `testone` (`id` INT UNSIGNED AUTO_INCREMENT,
`contents` TEXT NOT NULL,
PRIMARY KEY(`id`)
)ENGINE=MYISAM DEFAULT CHARSET=utf8;
删除数据表:drop table testone;
插入内容:INSERT INTO testone(id,contents)
VALUES
(NULL,"测试一下");
更新语句:update testone set id=4,contents="今天是阴天" where id=1;
field like %condition%
union 操作符
select * from table1 where condition1
union all|distinct
select * from table2 where condition2
默认就是把重复的语句删除,所以distinct写不写无影响
order by asc(升序) desc(降序)
group by 在分组的列上我们可以使用count sum avg 等函数
inner join select * from table1 inner join table2 on table1.id=table2.infoid;
left join
right join
IS NULL
IS NOT NULL
select name from table where name REGEXP '^st';
BEGIN 开始一个事务
ROLLBACK 事务回滚
COMMIT 事务确认
只有字innodb数据库引擎下才支持
alter table testone add i int;(添加字段)
alter table testone drop id;(删除字段)
alter table testone modify id char(10);(改变字段类型)
alter table testone change id ig int;(改变字段以及字段类型)
alter table testone engine=mysiam;
alter table testone modify name1 type1 first|after name2;
create index indexName on mytable(username(length));
SELECT VERSION( ) 服务器版本信息
SELECT DATABASE( ) 当前数据库名 (或者返回空)
SELECT USER( ) 当前用户名
SHOW STATUS 服务器状态
SHOW VARIABLES 服务器配置变量
SELECT * FROM runoob_tbl
-> INTO OUTFILE '/tmp/tutorials.txt';导出数据
OAD DATA LOCAL INFILE 'dump.txt' INTO TABLE mytbl;导入数据
(CREATE DATABASE IF NOT EXISTS FIREFLY DEFAULT CHARSET utf8 COLLATE utf8_general_ci;)创建的时候都是小写的firefly
删除数据库:drop database firefly;(这个一定要是小写)
选择数据库:use firefly;
创建数据表:create table if not exists `testone`(`id` int unsigned auto_increment,
`contents` text not null,
primary key(`id`)
)engine=myisam default charset=utf8;
CREATE TABLE IF NOT EXISTS `testone` (`id` INT UNSIGNED AUTO_INCREMENT,
`contents` TEXT NOT NULL,
PRIMARY KEY(`id`)
)ENGINE=MYISAM DEFAULT CHARSET=utf8;
删除数据表:drop table testone;
插入内容:INSERT INTO testone(id,contents)
VALUES
(NULL,"测试一下");
更新语句:update testone set id=4,contents="今天是阴天" where id=1;
field like %condition%
union 操作符
select * from table1 where condition1
union all|distinct
select * from table2 where condition2
默认就是把重复的语句删除,所以distinct写不写无影响
order by asc(升序) desc(降序)
group by 在分组的列上我们可以使用count sum avg 等函数
inner join select * from table1 inner join table2 on table1.id=table2.infoid;
left join
right join
IS NULL
IS NOT NULL
select name from table where name REGEXP '^st';
BEGIN 开始一个事务
ROLLBACK 事务回滚
COMMIT 事务确认
只有字innodb数据库引擎下才支持
alter table testone add i int;(添加字段)
alter table testone drop id;(删除字段)
alter table testone modify id char(10);(改变字段类型)
alter table testone change id ig int;(改变字段以及字段类型)
alter table testone engine=mysiam;
alter table testone modify name1 type1 first|after name2;
create index indexName on mytable(username(length));
SELECT VERSION( ) 服务器版本信息
SELECT DATABASE( ) 当前数据库名 (或者返回空)
SELECT USER( ) 当前用户名
SHOW STATUS 服务器状态
SHOW VARIABLES 服务器配置变量
SELECT * FROM runoob_tbl
-> INTO OUTFILE '/tmp/tutorials.txt';导出数据
OAD DATA LOCAL INFILE 'dump.txt' INTO TABLE mytbl;导入数据
阅读全文
0 0
- mysql的一些笔记
- mysql的一些笔记
- mysql的一些学习笔记。
- 一些常用的MySQL命令脚本笔记
- MySQL数据库优化的一些笔记
- MySQL触发器、存储过程、自定义函数、视图的一些笔记
- MySQL学习第五篇:Xtrabackup的一些使用笔记
- 学习MySQL的一些记录笔记(1)10-28
- 学习MySQL的一些记录笔记(2)11-06
- MySQL笔记以及一些技巧
- MySQL的一些的一些的一些
- mysql的一些操作
- MySQL的一些数据类型
- mysql 的一些函数
- MySQL的一些注意事项
- mysql的一些特性
- 关于Mysql的一些
- mysql的一些注意事项
- Git 问题及总结
- 从流程上对rtmp协议经行总结
- fastdfs 状态
- shell一键安装LNMP包
- Hbase--Show cluster status. Can be ‘summary’, ‘simple’, or ‘detailed’. The default is ‘summary’
- mysql的一些笔记
- 关于java静态方法里只能调用静态变量的思考
- 理解Android硬件加速的小白文
- descendantFocusability的用法
- Android 的进程间通信 Binder——Messenger的入门使用
- java.lang.NullPointerException Attempt to invoke virtual method 'int android.widget.Editor
- 关于Lua那些事
- 16.Python
- Java 对象和类