一、创建及删除用户
1、create session:允许连接数据库;
2、connect:基本操作表的权限,比如增删改查;
3、resource:创建一些函数,比如簇、索引,创建表、列等 ;
4、dba:系统管理员权限;
5、grant all privileges to B;将所有权限授予B(一个用户修改另一个用户的表,跨库查询);
6、如果你不用双引号建用户,不管你输入是大还是小写,它都会统一建为大写的用户,同样在删除的时候不用引号,也不管大小写了。
1、create user 用户名 identified by 用户密码 default tablespace 表空间名;
2、grant create session(权限) to 用户名;--授权(不授权的话不能登录)
3、drop user 用户名 cascade;
4、alter user sj_sys identified by 123 --重置用户密码
二、创建及删除表空间
1、create tablespace 表空间名 datafile '路径' size 200M;
create tablespace user1 datafile 'd:\test\a.dbf' size 200M autoextend on next 5M maxsize 1000M;
2、--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;
--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;
3、查询有哪些表空间
select tablespace_name from dba_tablespaces;
三、查询用户的相关信息
select * from dba_users;--管理员级别
select * from user_users;--用户级别
四、删除已连接用户
1、先结束要删除用户的连接
1)select username,sid ,serial# from v$session where username='WAHAHA';--用户名大写,否则提示未选定行(查询该用户的sid和serial)
2)alter system kill session 'sid,serial';
2、删除用户
drop user wahaha cascade;
3、解锁用户
alter user scott account unlock;
五、重命名列名:
alter table 用户名.表名 rename column 旧列名 to 新列名;