博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql学习笔记(二)
阅读量:4079 次
发布时间:2019-05-25

本文共 2333 字,大约阅读时间需要 7 分钟。

15索引

空间索引是对空间数据类型的字段建立的索引。

mysql的空间数据类型:geometry、point、linestring、polygon

创建空间索引的列,必须将其声明为not null

mysql 使用spatial关键字进行扩展

mysql中只有myisam存储引擎支持空间索引。

全文索引类型为fulltext ,在定义索引的列上支持值得全文查找,允许在这些索引列中插入重复值和空值。可以在char、varchar、text类型的列上创建。mysql中只有myisam存储引擎支持全文索引。

union 、fulltext、spatial 唯一索引、全文索引、空间索引。

mysql>explain select * from table where a=10 \G(查看表的索引情况)

在已经建好的表上建索引

alter table tablename add (union\fulltext\spatial) index indexname (字段名(索引长度))

create(union\fulltext\spatial) index indexname on tablename(字段名)

删除索引

alter table tablename drop index indexname

drop index indexname on tablename

16存储过程

创建存储过程:create procedure sp_name

调用存储过程:call

创建函数:create function

游标:

declare cursor_name cursor for select_name

open cursor_name

fetch cursor_name into var_name

close cursor_name

//loop leave

add_name:loop

set @count =@count+1 ;

if @count=50 then leave add_name ;//leave 跳出循环

end loop add_name;

 

//loop iterate

create procedure doiterate()

begin

declare p1 int defaut 0;

my_loop :loop

set p1=p1+1;

if p1<10 then iterate my_loop; //重新执行 p1=p1+1

elseif p1>20 then leave my_loop;

end if ;

select 'p1 is between 10 and 20';

end loop my_loop;

end

 

//repeat

declare id int default 0;

repeat //重复执行循环,直到满足条件后退出

set id =id+1;

until id>=10

end repeat;

 

//while

declare i int default 0;

while i<10 do //重复执行循环过程

end while;

 

查看存储过程:

mysql> show procedure status like 'c%' \G

 

参看存储\函数的定义

mysql>show create procedure\ founction sp_name \G

 

从information_schema.Routines表中查看存储过程和函数的信息

select * from information_schema.Routines

where routine_name='sp_name';

 

修改存储过程\函数

alter procedure\function sp_name

 

删除存储过程\函数

drop procedure\function sp_name

 

17视图

创建视图

create view view_t (a,b,c,d) as select a,b,c,d from t;

查看视图的基本信息

mysql>descibe view_t;

 

查看视图的基本信息

mysql>show table status like '视图名' \G

 

查看创建视图的信息

mysql>show create view vie_t \G

 

在view表中查看视图的信息

mysql>select * from information.schema.views \G

 

使用create or replace view

mysql>create or replace view view_t as select * from t;

 

使用alter修改视图

mysql>alter view view_t as select * from t;

 

视图可以insert、update、delete,会改动视图对应的表中的数据

 

删除视图

mysql>drop view if exists view_t;

 

18触发器

create trigger trigger_name before\after insert\update\delete

on table_name for each row

begin

语句执行列表

end

 

查看触发器信息

mysql>show trigger \G;

 

在trigger表中查看触发器信息

mysql>selcet * from information_schema.trigger \G;

 

删除触发器

mysql>drop trigger trigger_name;

转载地址:http://udsni.baihongyu.com/

你可能感兴趣的文章
APM/Pixhawk飞行日志分析入门(苍穹四轴)
查看>>
我刚刚才完全清楚GPS模块的那根杆子是怎么固定安装好的
查看>>
去github里面找找也没有别人无人机+SLAM的工程
查看>>
PX4与ROS关系以及仿真控制(键盘控制无人机)
查看>>
我对无人机重心高度的理解
查看>>
现在明白为什么无名博客里好几篇文章在讲传感器的滞后
查看>>
无人机不装脚架的好处就是降落时会比较稳,不怕倾斜侧翻。
查看>>
实际我看Pixhawk定高模式其实也是飞得很稳,飘得也不厉害
查看>>
我现在发现开课吧的智能无人机课程里面也讲GAAS
查看>>
Pixhawk解锁常见错误
查看>>
C++的模板化等等的确实比C用起来方便多了
查看>>
ROS是不是可以理解成一个虚拟机,就是操作系统之上的操作系统
查看>>
用STL algorithm轻松解决几道算法面试题
查看>>
ACfly之所以不怕炸机因为它觉得某个传感器数据不安全就立马不用了
查看>>
我发觉,不管是弄ROS OPENCV T265二次开发 SDK开发 caffe PX4 都是用的C++
查看>>
ROS的安装(包含文字和视频教程,我的ROS安装教程以这篇为准)
查看>>
国内有个码云,gitee
查看>>
我居然在GAAS的硬件清单上看到了权盛光流,又想起ZN无人机课程他们购买无人机配件也是在权盛
查看>>
原来我之前一直用的APM固件....现在很多东西明白了。
查看>>
realsense-ros里里程计相关代码
查看>>