oracle之index

--查看用户对象
SELECT OBJECT_NAME,OBJECT_TYPE FROM USER_OBJECTS;
--创建普通索引(指定pctfree,表空间,nologging模式)
create index fei_idx3 on fei(pwd,name) pctfree 20 tablespace users nologging;
--创建唯一索引
 create unique index fei_idx1 on fei(id) pctfree 20 tablespace users nologging;
--创建bitmap index
create bitmap index fei_idx1 on fei(id) pctfree 20 tablespace users nologging;
--修改索引空间大小(增大)
alter index fei_idx1 allocate extent(size 2000k
datafile 'C:\oracle\product\10.2.0\oradata\orcl\users01.dbf');
--释放索引未空间
alter index fei_idx1 deallocate unused;
--rebuild索引(在线索引重建)
alter index fei_idx1 rebuild online;
--删除索引
drop index fei_idx1;
--coalescing 索引(索引融合    相当于windows的磁盘整理功能)
alter index fei_idx1 coalesce;
--对索引分析(判断该索引是否要rebuild,主要参数是lf_rows,del_lf_rows的比例)
analyze index fei_idx1 validate structure offline;
select * from index_stats;
--监控索引使用情况
alter index fei_idx1 monitoring usage;--开启监控
select * from v$object_usage;--监控的结果
alter index fei_idx1 nomonitoring usage;--关闭监控
--查看执行计划
set autot on exp;--开启
set autot off;--关闭
--相关视图查询
select * from dba_ind_columns WHERE INDEX_OWNER='CHF';
select * from dba_indexes where owner='CHF';
SELECT * FROM DBA_IND_STATISTICS WHERE owner='CHF';

mysql 用户管理

1、创建用户:
create user fei@’localhost’ identified by ‘fei’;
note:该用户没有授予任何访问权限,如果不加@’localhost’默认为“@%”

2、用户授权:
grant delete on test.* to fei@’localhost’ with grant option;
note:1)*表示test的任何对象,如果是*.*表示数据库中的所有对象
2)with grant option 表明fei用户可以把相关权限授给其他用户

3、权限回收:
revoke delete on test.* from fei@’localhost’;

4、创建用户授权一起实现
grant select,insert,update,delete on *.* to ‘fei2’@’%’
identified by ‘fei2’ with grant option;
note:在mysql中,如果@后面的登录范围不同,帐号可以一样

5、直接使用insert建立用户
insert into user(host,user,password,ssl_cipher,x509_issuer,x509_subject)
values(‘localhost’,’xff’,password(‘xff’),”,”,”);
FLUSH PRIVILEGES;
note:1)必须要加上ssl_cipher,x509_issuer,x509_subject三列,以为其默认值不为空(数据库版本为:5.0.51b)
2)FLUSH PRIVILEGES重载授权表,使权限更改生效
3)mysql是通过User表,Db表,Host表,Tables_priv 表,Columns_priv 表这5张表实现用户权限控制,均可以通过直接对这些表的操作以达到对用户的管理

6、删除用户:
drop user xff@localhost;(@不加默认为“%”)

7、授权精确到列:
grant select (cur_url,pre_url) on test.abc to fei@localhost;

8、修改root密码:
update mysql.user set password=password(‘passw0rd’) where user=’root’;
FLUSH PRIVILEGES;