1.查看oracle服务器中有几个数据库,使用以下语句。
select instance_name from v$instance;
2.查看oracle服务器上有几个表空间,用system登陆
select distinct s.default_tablespace from DBA_USERS s;
3.查看某个表空间下有哪些用户
select * from DBA_USERS s where s.default_tablespace ='表空间名';
4.删除不需要的用户,此用户下的表也删除。
drop user 用户名 cascade;
5.备份某张表
create table table_backup as select * from tablename;--table_backup新表,tablename要复制的表
如果只要表结构,不要数据,create table table_backup as select * from tablename where 1=2;就行了。
6.根据约束名查找此约束所在的表名
select uc.TABLE_NAME from user_constraints uc where uc. CONSTRAINT_NAME='约束名';--user_constraints约束表,记录该用户的所有约束。如非空,索引等等。
select * from user_constraints;
7.如何查到某个表的主键被哪些表约束作为外键
select a.constraint_name, a.table_name, b.constraint_name
from user_constraints a, user_constraints b
where a.constraint_type = 'R'--R 代表外键
and b.constraint_type = 'P'--P 代表主键
and a.r_constraint_name = b.constraint_name
and b.constraint_name=约束名;
8.设置oracle数据库最大连接数,当数据库最大连接数不够时会出现客户端连接间歇性失败,报错ORA-12519。
select count(*) from v$process; --查看当前连接数
select value from v$parameter where name = 'processes' ; --查看数据库设置的最大连接数
alter system set processes = 300 scope = spfile; --将最大连接数修改为300
重启服务器,OK。