索引
查看索引
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