mysql 存储过程、函数、索引、视图的一些系统命令

索引

查看索引

 show index from tablename;
 show keys from tablename;


创建索引

  create index index_name on table_name(column_list) 普通索引
  create unique index index_name on table_name(column_list) 唯一索引

 

删除索引

  drop index index_name on table_name
  alter table table_name drop index index_name
  alter table table_name drop primary key

 

 

存储过程及函数

查看存储过程及函数

  select name from mysql.proc where db='db_name' and type='PROCEDURE'
  show procedure status;

  select name from mysql.proc where db='db_name' and type='function'
  show function status;


查看存储过程与函数内容

  show create procedure pro_name;
  show create function func_name;


创建函数

  show variables like '%func%' ; 查看创建函数功能是否开启
 
  set global log_bin_trust_function_creators=1;  开启创建函数功能
 
  use db_name;
  delimiter $$  设置$$为命令终止符号,代替分号,因为分号会在函数中用到
  create function func_name(param1 varchar(5),param2 varchar(5))
  RETURNS int
  begin
    return 1;
  end $$
 
  delimiter ;

使用函数

  select func_name('','');

删除函数

  drop function func_name;


视图及表

查看视图及表

  select * from information_schema.VIEWS
  select * from information_schema.TABLES


触发器

查看触发器

   select * from information_schema.TRIGGERS;


其他数据库参数查看

  help show
  show global status
  show global variables
  show full processlist
  show engines
  show status
  desc tablename
  show databases
  use database_name

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值