Oracle下session的查询与删除 1、查询当前session SQLgt; select username,sid,serial# from v$session where username is not
Oracle下session的查询与删除
1、查询当前sessionSQL> select username,sid,serial# from v$session where username is not null;
USERNAME SID SERIAL#
------------------------------ ---------- ----------
SYS 144 4
HYL 146 48
SCOTT 147 64
HR 159 15
--SERIAL#:SID有可能会重复,,当两个session的SID重复时,SERIAL#用来区别session
SQL> alter system kill session '146,48';
System altered.
hyl的session下执行操作如下:
SQL> show user
USER is "HYL"
SQL> select * from test1;
select * from test1
*
ERROR at line 1:
ORA-00028: your session has been killed
--------------------------------------------------------------------------------
Linux-6-64下安装Oracle 12C笔记
在CentOS 6.4下安装Oracle 11gR2(x64)
Oracle 11gR2 在VMWare虚拟机中安装步骤
Debian 下 安装 Oracle 11g XE R2
--------------------------------------------------------------------------------
3、删除当前session的用户思路:先关闭session,然后再删除用户
演示:在不关闭session的情况下删除用户现象:
SQL> select username,account_status from dba_users;
--查看当前有哪些用户
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
CSMIG OPEN
MGMT_VIEW OPEN
SYS OPEN
SYSTEM OPEN
HYL OPEN
OE EXPIRED & LOCKED
6 rows selected.
SQL> select username,sid,serial# from v$session where username is not null;
--通过v$session视图,查看会话的sid、serial#
USERNAME SID SERIAL#
------------------------------ ---------- ----------
SYS 144 4
HYL 146 54
SCOTT 147 64
HR 159 15
SQL> drop user hyl; --删除,报错了,表明会话中存在的用户是不能被删除的,需要先将其关闭
drop user hyl
*
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected
SQL> alter system kill session '146,54';
System altered.
User dropped.
--尝试hyl连接,报错,无法使用hyl登陆session
SQL> conn hyl/oracle
ERROR:
ORA-01017: invalid username/password; logon denied
Warning: You are no longer connected to ORACLE.
--查看dba_users数据字典,表明hyl用户已经被删除
SQL> select username,account_status from dba_users;
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
CSMIG OPEN
MGMT_VIEW OPEN
SYS OPEN
SYSTEM OPEN
OE EXPIRED & LOCKED
5 rows selected.
小结:
查询当前会话:select username,sid,serial# from v$session where username is not null;
删除当前会话:alter system kill session 'sid,serial#';
删除当前会话的用户,先kill session,再drop user(若用户下有对象,使用cascade命令)
更多详情见请继续阅读下一页的精彩内容:

How to effectively monitor MySQL performance? Use tools such as mysqladmin, SHOWGLOBALSTATUS, PerconaMonitoring and Management (PMM), and MySQL EnterpriseMonitor. 1. Use mysqladmin to view the number of connections. 2. Use SHOWGLOBALSTATUS to view the query number. 3.PMM provides detailed performance data and graphical interface. 4.MySQLEnterpriseMonitor provides rich monitoring functions and alarm mechanisms.

The difference between MySQL and SQLServer is: 1) MySQL is open source and suitable for web and embedded systems, 2) SQLServer is a commercial product of Microsoft and is suitable for enterprise-level applications. There are significant differences between the two in storage engine, performance optimization and application scenarios. When choosing, you need to consider project size and future scalability.

In enterprise-level application scenarios that require high availability, advanced security and good integration, SQLServer should be chosen instead of MySQL. 1) SQLServer provides enterprise-level features such as high availability and advanced security. 2) It is closely integrated with Microsoft ecosystems such as VisualStudio and PowerBI. 3) SQLServer performs excellent in performance optimization and supports memory-optimized tables and column storage indexes.

MySQLmanagescharactersetsandcollationsbyusingUTF-8asthedefault,allowingconfigurationatdatabase,table,andcolumnlevels,andrequiringcarefulalignmenttoavoidmismatches.1)Setdefaultcharactersetandcollationforadatabase.2)Configurecharactersetandcollationfor

A MySQL trigger is an automatically executed stored procedure associated with a table that is used to perform a series of operations when a specific data operation is performed. 1) Trigger definition and function: used for data verification, logging, etc. 2) Working principle: It is divided into BEFORE and AFTER, and supports row-level triggering. 3) Example of use: Can be used to record salary changes or update inventory. 4) Debugging skills: Use SHOWTRIGGERS and SHOWCREATETRIGGER commands. 5) Performance optimization: Avoid complex operations, use indexes, and manage transactions.

The steps to create and manage user accounts in MySQL are as follows: 1. Create a user: Use CREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password'; 2. Assign permissions: Use GRANTSELECT, INSERT, UPDATEONmydatabase.TO'newuser'@'localhost'; 3. Fix permission error: Use REVOKEALLPRIVILEGESONmydatabase.FROM'newuser'@'localhost'; then reassign permissions; 4. Optimization permissions: Use SHOWGRA

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

The disadvantages of MySQL compared to other relational databases include: 1. Performance issues: You may encounter bottlenecks when processing large-scale data, and PostgreSQL performs better in complex queries and big data processing. 2. Scalability: The horizontal scaling ability is not as good as Google Spanner and Amazon Aurora. 3. Functional limitations: Not as good as PostgreSQL and Oracle in advanced functions, some functions require more custom code and maintenance.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),