mysql查看索引与存储过程

创建索引:
CREATE INDEX可对表增加普通索引或UNIQUE唯一索引。
CREATE INDEX index_name ON table_name (column_list)
CREATE UNIQUE INDEX index_name ON table_name (column_list)

ALTER TABLE用来创建普通索引、UNIQUE索引或PRIMARY KEY主键。

ALTER TABLE table_name ADD INDEX index_name (column_list)
ALTER TABLE table_name ADD UNIQUE (column_list)
ALTER TABLE table_name ADD PRIMARY KEY (column_list)

查看索引

mysql> show index from tablename;
mysql> show keys from tablename;
Non_unique 唯一约束为0。非唯一约束为1。

删除索引

可利用ALTER TABLE或DROP INDEX语句来删除索引
 DROP INDEX index_name ON talbe_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 proc_name;
show create function func_name;
如果需要修改存储过程与函数,先drop 再create.

其它数据库参数查看:

mysql> help show
mysql> Show Global Status,
mysql> Show global variables,
mysql> Show full processlist,
mysql> show engines;
mysql> show status;
mysql> desc tablename;
mysql> show databases;
mysql> use database_name;