--oracle删除某个用户下的所有表
--此句只是查询并且拼接sql,然后将执行的sql复制然后运行即可
select 'drop table '||table_name||';' from cat where table_type='TABLE';
export ORACLE_SID=数据库实例名
--windows的切换方法是 sqlplus "/@实例名称 as sysdba"
sqlplus /nolog
conn /as sysdba
--查看当前用户
show user;
--查看当前数据库实例(表空间)
show parameter instance_name;
--oracle查询某个实例下的所有用户
select username from 实例名.all_users;
--创建表空间orcl_miit
create tablespace orcl_miit datafile '/data/oracle/oradata/orcl/orcl_miit.dbf' size 10M autoextend on next 10M MAXSIZE UNLIMITED;;
--修改表空间的名称
alter tablespace orcl_miit rename to orcl_miit_new;
--删除表空间
DROP TABLESPACE orcl_miit INCLUDING CONTENTS AND DATAFILES;
--删除空的表空间,但是不包含物理文件
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;
--为表空间增加自动扩展
alter database datafile '/data/oracle/oradata/orcl/orcl_miit.dbf' AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED;
--查询用户属于那个表空间
select username,default_tablespace from dba_users where username='ORCL_MIIT';
--创建用户orcl_miit密码为123:
create user orcl_miit identified by 123;
ser$ where name ='orcl_miit';
USER# NAME PASSWORD
---------- ------------------------------ ------------------------------
78 TICKETS 21EDA78F89D6FACD
SQL> update user$ set name='orcl_miit1' where user#=78;
1 row updated.
SQL> commit;
Commit complete
-----------------------------------------------------
--删除用户orcl_miit以及用户所有的对象
drop user orcl_miit cascade;
--指定用户表空间:
alter user orcl_miit default tablespace orcl_miit;
--授权登录
grant connect, resource, dba to orcl_miit;
grant create session to orcl_miit;
--监听
lsnrctl start/restart/stop
--查询实例
select name from v$databas
--打开图形化界面
export DISPLAY=:1.0
xhost +
--oracle删除某个用户下的所有表
--此句只是查询并且拼接sql,然后将执行