2013年3月4日星期一

mysql 常用函数


#分配权限
GRANT ALL PRIVILEGES ON *.* TO work@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

#oracle 查看表的注释 及查看数据库所有表的命令 及查看各表注释
select   *   from   user_col_comments where table_name='BRANDAD'
select * from user_tables where table_name like '%BRAND%'
select   *   from   user_tab_comments where table_name like '%AGENT%'


#查询不输出表头
${mysql} -N -e "查询sql"
注意:此贴为原创,转载请标明出处

#增加 删除索引
create index `idx_s_date`  on t_cust_day_2012(`s_date`)
create index `idx_e_date`  on t_cust_day_2012(`e_date`)
drop index `idx_s_date_e_date` on t_cust_day_2012


#好的Mysql 性能优化文章
http://www.oicto.com/mysql-explain-show/

LEFT(str,len)
返回字符串str的最左面len个字符

RIGHT(str,len)
返回字符串str的最右面len个字符

select * from t_agent_user_info where agent_user_name='sd'

select * from t_agent_user_info where agent_user_name='SD'
结果一样 字母不区分大小写

mysql按中文守字符排
select realname from t_user_info order by convert(realname USING gbk)

mysql 重启
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/zyd/mysql3307/my.cnf --user=root &

/usr/local/mysql/bin/mysqladmin  -uroot -P3307 -h127.0.0.1 -ptest123  shutdown

没有评论:

发表评论