大家好,又见面了,我是你们的朋友全栈君。
oracle基本操作
desc all_tables; –查看表结构
select from all_tables;–查看当前数据库所有的表
select table_name from user_tables;查看当前登录的用户的表:
select from dba_users;查看有哪些用户
修改密码过期策略
1.查看用户存放密码策略的proifle:
SELECT USERNAME,PROFILE FROM DBA_USERS;
2.查看当前的密码策略过期天数
SELECT * FROM DBA_PROFILES WHERE PROFILE=’DEFAULT’ AND RESOURCE_NAME=’PASSWORD_LIFE_TIME’;
3.修改密码过期策略
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
4.登录dba或者有权限的用户更改密码
DBA更改:
alter user test IDENTIFIED BY 123456;
普通用户更改用户密码:
ALTER USER test IDENTIFIED BY 新密码 replace 旧密码
dba用户更改密码:
ALTER USER test IDENTIFIED BY 123456
普通用户更改用户密码:
ALTER USER test IDENTIFIED BY 新密码 replace 旧密码
登录DBA用户
sqlplus system/oracle as sysdba
修改最大连接数和会话数
col sid for 9999
col serial# for 99999
col username for a10
col program for a20
col machine for a20
1.查询数据库当前进程的连接数:
select count() from v$process;
2.查看数据库当前会话的连接数:
select count() from v$session;
3.查看数据库的并发连接数:
select sid,serial#,username,program,machine,status from v$session where status=’ACTIVE’;
4.查看当前数据库建立的会话情况:
select sid,serial#,username,program,machine,status from v$session;
5.修改数据库允许的最大连接数:
alter system set processes = 600 scope = spfile;
6.修改数据库允许的最大会话数:
在修改最大连接数时,最大会话数会自动修改
查看连接数
show parameter processes
查看会话数
show parameter session
查看默认连接数processes是150
SQL> show parameter process
NAME TYPE VALUE
aq_tm_processes integer 0
cell_offload_processing boolean TRUE
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
job_queue_processes integer 0
log_archive_max_processes integer 4
processes integer 150
查看默认会话数sessions是247
SQL> show parametere session
SP2-0158: unknown SHOW option “parametere”
SP2-0158: unknown SHOW option “session”
SQL> show parameter session
NAME TYPE VALUE
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
session_cached_cursors integer 50
session_max_open_files integer 10
sessions integer 247
shared_server_sessions integer
修改连接数到600,最大会话数会自动更改为922
变化公示:
sessions=processes*1.5 22
SQL> alter system set processes = 600 scope = spfile;
System altered.
不重新启动数据库会话数和连接数不变化
SQL> show parameter session
NAME TYPE VALUE
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
session_cached_cursors integer 50
session_max_open_files integer 10
sessions integer 247
shared_server_sessions integer
SQL> show parameter process;
NAME TYPE VALUE
aq_tm_processes integer 0
cell_offload_processing boolean TRUE
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
job_queue_processes integer 0
log_archive_max_processes integer 4
processes integer 150
重新启动下数据库、类似nginx的reload
SQL> startup force
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2217464 bytes
Variable Size 562039304 bytes
Database Buffers 218103808 bytes
Redo Buffers 2637824 bytes
Database mounted.
Database opened.
会话数和连接数更改
SQL> show parameter process;
NAME TYPE VALUE
aq_tm_processes integer 0
cell_offload_processing boolean TRUE
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
job_queue_processes integer 0
log_archive_max_processes integer 4
processes integer 600
SQL> show parameter session;
NAME TYPE VALUE
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
session_cached_cursors integer 50
session_max_open_files integer 10
sessions integer 922
shared_server_sessions integer
SQL>
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/164693.html原文链接:https://javaforall.cn