SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database

Manish Sharma · Beginner ·📊 Data Analytics & Business Intelligence ·11y ago

Key Takeaways

Drops a user account in an Oracle database when connected or not connected to the database

Full Transcript

was a burden a diamond is from rebellionrider.com and today I'm going to do a bonus equal tutorial which is all about how to drop a user I know you must be thinking what is so special about it yes I agree that dropping a user is fairly simple task when user is not connected to the database but what if user is connected to your database then what will you do in that case dropping a user can be quite tricky being a database administrator creating and dropping a user is one of the most frequent tasks that you will have to perform till now I have shown you three different ways of creating a user in Oracle database if you haven't watched these tutorial then please find the link in the description box having said that today I will show you how to drop a user when it is connected to the database and when it is not connected to the database as well so let's start today's tutorial first we will see how to drop a user which is not connected to the database to drop a user you must have either drop user system privilege or you must log on to your database using sis user with system your privileges I have 3 user by the name of Ironman Batman and Superman which I created in my previous tutorial on how to create a user right now I am not connected with any of them and I'm going to drop these 3 user in today's tutorial for the demonstration so first I will connect to my database using my sis u services DBA privileges I have already created a connection by the name of sis at localhost if you don't know how to make this connection using sis user please watch my tutorial 38 where in the first half I have explained how to make connection which says user so let's try to connect to a database using sis user so we are connected to the database using sis user let me show you the user was user is sis now I am going to drop a user Ironman user Ironman is not connected to the database this user does not on any object such as tables indexes views etc etc this means I have not created any tables sequences indexes or anything using this user this is just an empty user in this case when user does not on any object you can simply write drop user followed by username which you want to drop so to drop user Ironman we will write just a simple Kure drop user followed by the name of user which you want to drop in our case it's Ironman now let's execute this Kure user Ironman is draw in case user on some object that is if you have created tables or indexes or anything using the user then we use cascade dropping I have created a table in user Batman for the demonstration let's first try to drop this user normally let's execute you got an error now just add cascade keyword in this drop user Kure right after the username which is Batman but first let me close this script output okay now add cascade right after the username which is Batman now let's try to execute this query and user Batman dropped so till now we have seen how to drop a user which are not connected to the database now let's see how to drop a user which is connected to the database for the demonstration purpose I will use user Superman let's first connect to the database using this user Superman for this I will use command prompt let me show you the user as you can see now we are connected to the database using this user Superman now let's come back over sequel developer and try to drop it using drop user come on let me close this script output first now we will try to drop a user Superman which is now connected to our database execute we got an error just to be clear let's also try cascade drop let me again close this script output again error let's assume this user Superman is a user with malicious intention to hamper your database and you caught this while auditing and now you want to drop this user the first thing which comes into the mind is just to disconnect this user and then drop it what if as soon as you disconnect this user it reconnect itself like this you will stuck into a loop and won't be able to drop it so you have to make sure that after you disconnect the user it will not be able to reconnect itself to the database there are series of steps which you have to perform to do this task of dropping this user and I am going to demonstrate all these steps now first let me close this script output and let me also minimize this connection tab okay everything is perfectly visible to you guys I think now step one make sure you are connected to your database using sis user and sister B of privileges I am already connected to my database Vicis user step 2 now you have to put your database into restricted mode there are two ways of doing so first is shut down your database completely and then started with startup restrict option I don't think this is a wise option as you will probably not want to disturb all the database user just for dropping a single user and get fired the next morning second option which I recommend is using alter system come on let me show you how as I have already told you that you must be login as a sis you services DBA privileges once you have done that then right just execute this command system enabled altered by default our database is in open startup mode now we just change the mode from open to restricted when the database is started in a restricted mode the user that are already connected can continue their work without any interruptions unless they are somehow disconnected once any of them are disconnected they have to have a restricted session privilege which is a special system privilege to connect with the database again furthermore no new user can connect with the database step 3 now we have to get this session identifier and this serial number of the user which we want to drop for that we will use we dollar session view such as this curie is fairly simple we are retrieving s ID which is session identifier not the database s ID which is stand for system identifier and the serial number from v dollar session view and we have our where clause where we have specified the user name make sure user name will be in all caps and enclosed in single quotes now let's execute this query here we get the s ID and serial number of the user Superman which we are going to delete now step 4 in this step we will disconnect the user Superman from the database and as we are in restricted mode then this user will not be able to reconnect to the database that's the purpose of restricted mode using the S ID and serial number which we obtained in the previous step we will now kill the session or say disconnect the user for that just write the queue let's execute this QD system kill altered now this user is disconnected from the database and you are all free to drop it now step 5 drop the user let me first close this script output panel and this Curie result also using drop user command you can drop this user as we did at the starting of this tutorial if this user has object then use drop user cascade command otherwise simple drop user comma in my case I will use costly dropping okay let's execute this drop user command user Superman is dropped now step 6 the final step now user has been dropped but our database is still into the restricted mode we have to bring our database back into the normal mode in step 2 we enable the restricted session now we will disable it for that we will again write an alter system Curie s let me again close this script output now let's write the Curie let's execute system disabled all turn that's it that's all you have to do you can also visit my blog where I have written every step in DT link is in the description box hope you learned something please tell me how you liked this video and do you want more such videos just leave a comment below also please like my video this makes me really happy and keep me motivated I am very thankful to you all guys signing off for today we'll see you soon guys with another amazing sequel tutorial till then take care keep watching and liking my videos and don't forget to subscribe thank you this is manish from rebellionrider

Original Description

Watch in HD,Dropping a user is easy only when it is not connected to the database what if it is connected. Learn how to drop a user when it is connected to the database as well as when it is not connected, along with the cascade drop and introduction of Startup RESTRICT mode of Oracle database. ------------------------- Topics cover 1. Drop user when it is not connected to the database 2. Drop user cascade 3. Drop user when it is connected to the database 4. How to kill a session 5. Oracle Start-up Restrict 6. What is Restrict Start-up and why we use it. Please please LIKE and SHARE my videos it makes me happy. Links: Detail Blog (Must Read) http://bit.ly/drop-user Tutorial 38 Create user using SQL Developer http://youtu.be/GS4udgR44Ls Tutorial 37 Create user using SQL create user statement http://youtu.be/4QbK2Y-1LZw Tutorial 39 create user using EM http://youtu.be/zGjh-Bb3HrI Copy Cloud referral link || Use this link to join copy cloud and get 20GB of free storage https://copy.com?r=kb4rc1 Amazon Wishlist: http://bit.ly/wishlist-amazon Follow What I am up to as it happens on Twitter https://twitter.com/rebellionrider Instagram http://instagram.com/rebellionrider Facebook. https://www.facebook.com/imthebhardwaj Linkedin. http://in.linkedin.com/in/mannbhardwaj/ You can also Email me at RebellionRiderYT@gmail.com Thanks for liking, commenting, sharing and watching more of our videos This is Manish from RebellionRider.com
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Manish Sharma · Manish Sharma · 46 of 60

1 Oracle Database tutorials 1: How to install Oracle Database 11g on windows 7
Oracle Database tutorials 1: How to install Oracle Database 11g on windows 7
Manish Sharma
2 Oracle Database tutorials 2:How To install SQL Developer on windows 7
Oracle Database tutorials 2:How To install SQL Developer on windows 7
Manish Sharma
3 Oracle Database tutorials 3:How to enable Line numbers in SQL Developer.
Oracle Database tutorials 3:How to enable Line numbers in SQL Developer.
Manish Sharma
4 Oracle Database tutorials 4:  database connectivity using SQL developer and command prompt
Oracle Database tutorials 4: database connectivity using SQL developer and command prompt
Manish Sharma
5 Oracle Database tutorials 5:  how to Fetch Data using SELECT - SQL statement by Manish Sharma
Oracle Database tutorials 5: how to Fetch Data using SELECT - SQL statement by Manish Sharma
Manish Sharma
6 Oracle Database11g tutorials 6 | | How to use Concatenation operator, character String
Oracle Database11g tutorials 6 | | How to use Concatenation operator, character String
Manish Sharma
7 Oracle Database11g tutorials 7 | |SQL DISTINCT keyword || SQL tutorials
Oracle Database11g tutorials 7 | |SQL DISTINCT keyword || SQL tutorials
Manish Sharma
8 Canon EOS 600D 2 lens kit/Canon rebell EOS T3i 2 lens kit Unboxing
Canon EOS 600D 2 lens kit/Canon rebell EOS T3i 2 lens kit Unboxing
Manish Sharma
9 First look: ORACLE CERTIFIED ASSOCIATE (OCA) CERTIFICATE  - ORACLE DATABASE ADMINISTRATOR
First look: ORACLE CERTIFIED ASSOCIATE (OCA) CERTIFICATE - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
10 Oracle Database11g tutorials 8 || SQL DISTINCT with multiple columns |SQL Distinct with Two columns
Oracle Database11g tutorials 8 || SQL DISTINCT with multiple columns |SQL Distinct with Two columns
Manish Sharma
11 Oracle Database11g tutorials 9 || What is archive log mode and how to enable archive log mode
Oracle Database11g tutorials 9 || What is archive log mode and how to enable archive log mode
Manish Sharma
12 Oracle Database11g tutorials 10 ||  SQL Single Row Function (SQL Functions )
Oracle Database11g tutorials 10 || SQL Single Row Function (SQL Functions )
Manish Sharma
13 Oracle Database11g tutorials 11: SQL case manipulation function in Oracle Database
Oracle Database11g tutorials 11: SQL case manipulation function in Oracle Database
Manish Sharma
14 how to add channel trailer and section on your youtube channel 2014
how to add channel trailer and section on your youtube channel 2014
Manish Sharma
15 Oracle Database11g tutorials 12 || SQL Concat Function - SQL character manipulation function
Oracle Database11g tutorials 12 || SQL Concat Function - SQL character manipulation function
Manish Sharma
16 Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Manish Sharma
17 Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
Manish Sharma
18 SQL tutorials 15 || How To CREATE TABLE using enterprise manager 11g
SQL tutorials 15 || How To CREATE TABLE using enterprise manager 11g
Manish Sharma
19 Oracle Database11g tutorials 16: How to uninstall oracle 11g from windows 7 64 bit
Oracle Database11g tutorials 16: How to uninstall oracle 11g from windows 7 64 bit
Manish Sharma
20 ORACLE CERTIFIED PROFESSIONAL(OCP) CERTIFICATE First look  - ORACLE DATABASE ADMINISTRATOR
ORACLE CERTIFIED PROFESSIONAL(OCP) CERTIFICATE First look - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
21 Plantronics audio 655 USB headset with Mic Unboxing and Review and Plantronics audio 655 Mic test
Plantronics audio 655 USB headset with Mic Unboxing and Review and Plantronics audio 655 Mic test
Manish Sharma
22 SQL tutorials 17: SQL Primary Key constraint,  Drop primary Key
SQL tutorials 17: SQL Primary Key constraint, Drop primary Key
Manish Sharma
23 SQL tutorials 18: SQL Foreign Key Constraint By Manish Sharma
SQL tutorials 18: SQL Foreign Key Constraint By Manish Sharma
Manish Sharma
24 SQL tutorial 19: ON DELETE SET NULL clause of Foreign Key By Manish Sharma (RebellionRider)
SQL tutorial 19: ON DELETE SET NULL clause of Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
25 SQL tutorials 20: On Delete Cascade Foreign Key By Manish Sharma (RebellionRider)
SQL tutorials 20: On Delete Cascade Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
26 SQL tutorial 21: How To Rename Table in SQL using ALTER TABLE statement By Manish Sharma
SQL tutorial 21: How To Rename Table in SQL using ALTER TABLE statement By Manish Sharma
Manish Sharma
27 SQL tutorial 22: How to Add / Delete column from an existing table using alter table
SQL tutorial 22: How to Add / Delete column from an existing table using alter table
Manish Sharma
28 SQL tutorial 23: Rename and Modify Column Using Alter Table By Manish Sharma (RebellionRider)
SQL tutorial 23: Rename and Modify Column Using Alter Table By Manish Sharma (RebellionRider)
Manish Sharma
29 SQL tutorial 24 :SQLJoins- Natural Join With ON and USING clause By Manish/Rebellionrider
SQL tutorial 24 :SQLJoins- Natural Join With ON and USING clause By Manish/Rebellionrider
Manish Sharma
30 Oracle Database11g tutorials 25: How to install Oracle Database 11g Express Edition R2 on Windows 7
Oracle Database11g tutorials 25: How to install Oracle Database 11g Express Edition R2 on Windows 7
Manish Sharma
31 SQL tutorial 26: Introduction to SQL Joins in Oracle Database
SQL tutorial 26: Introduction to SQL Joins in Oracle Database
Manish Sharma
32 Vidcon 2014 YouTube Fan Funding: How to enable fan funding on YouTube Channel
Vidcon 2014 YouTube Fan Funding: How to enable fan funding on YouTube Channel
Manish Sharma
33 SQL tutorial 27: Right Outer Join in SQL by Manish Sharma for RebellionRider
SQL tutorial 27: Right Outer Join in SQL by Manish Sharma for RebellionRider
Manish Sharma
34 SQL tutorial 28: Left Outer Join By Manish Sharma / RebellionRider
SQL tutorial 28: Left Outer Join By Manish Sharma / RebellionRider
Manish Sharma
35 SQL tutorial 29: Full Outer Join with example By Manish Sharma/ RebellionRider
SQL tutorial 29: Full Outer Join with example By Manish Sharma/ RebellionRider
Manish Sharma
36 SQL tutorial 30: Inner Join In SQL by Manish Sharma/RebellionRider
SQL tutorial 30: Inner Join In SQL by Manish Sharma/RebellionRider
Manish Sharma
37 SQL tutorial 31 : SQL Cross Join In Oracle Database By Manish Sharma from RebellionRider
SQL tutorial 31 : SQL Cross Join In Oracle Database By Manish Sharma from RebellionRider
Manish Sharma
38 SQL tutorial 32: How To Insert Data into a Table Using SQL Developer
SQL tutorial 32: How To Insert Data into a Table Using SQL Developer
Manish Sharma
39 SQL tutorial 33:How To Insert Data into a Table Using SQL INSERT INTO dml statement
SQL tutorial 33:How To Insert Data into a Table Using SQL INSERT INTO dml statement
Manish Sharma
40 SQL tutorial 34: How to copy /Insert data into a table from another table using INSERT INTO SELECT
SQL tutorial 34: How to copy /Insert data into a table from another table using INSERT INTO SELECT
Manish Sharma
41 SQL tutorial 35: DELETE and TRUNCATE how to delete data from a table
SQL tutorial 35: DELETE and TRUNCATE how to delete data from a table
Manish Sharma
42 SQL tutorial 36: how to create database using database configuration assistant DBCA
SQL tutorial 36: how to create database using database configuration assistant DBCA
Manish Sharma
43 SQL tutorial 37: How to create NEW USER account using Create User statement in Oracle database
SQL tutorial 37: How to create NEW USER account using Create User statement in Oracle database
Manish Sharma
44 SQL tutorial 38: How to create user using SQL Developer in Oracle database
SQL tutorial 38: How to create user using SQL Developer in Oracle database
Manish Sharma
45 SQL tutorial 39: How to create user in oracle using Enterprise Manager
SQL tutorial 39: How to create user in oracle using Enterprise Manager
Manish Sharma
SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database
SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database
Manish Sharma
47 Motorola Moto G 2nd Generation / G2 Unboxing and Review
Motorola Moto G 2nd Generation / G2 Unboxing and Review
Manish Sharma
48 SQL tutorial 41: How to UNLOCK USER in oracle Database
SQL tutorial 41: How to UNLOCK USER in oracle Database
Manish Sharma
49 SQL tutorial 42: How to Unlock user using SQL Developer By Manish Sharma RebellionRider
SQL tutorial 42: How to Unlock user using SQL Developer By Manish Sharma RebellionRider
Manish Sharma
50 SQL tutorial 43: How to create an EXTERNAL USER in oracle database By Manish Sharma RebellionRider
SQL tutorial 43: How to create an EXTERNAL USER in oracle database By Manish Sharma RebellionRider
Manish Sharma
51 SQL tutorial 44: How to import data from Microsoft Excel to Oracle Database using SQL Developer
SQL tutorial 44: How to import data from Microsoft Excel to Oracle Database using SQL Developer
Manish Sharma
52 SQL tutorial 45: Introduction to user Privileges in Oracle Database By Manish Sharma RebellionRider
SQL tutorial 45: Introduction to user Privileges in Oracle Database By Manish Sharma RebellionRider
Manish Sharma
53 SQL tutorial 46: What are System Privileges & How To Grant them using Data Control Language
SQL tutorial 46: What are System Privileges & How To Grant them using Data Control Language
Manish Sharma
54 SQL tutorial 47: How to Grant Object Privileges With Grant Option in Oracle Database
SQL tutorial 47: How to Grant Object Privileges With Grant Option in Oracle Database
Manish Sharma
55 SQL tutorial 48: How to create Roles in Oracle Database
SQL tutorial 48: How to create Roles in Oracle Database
Manish Sharma
56 SQL tutorial 49: CASE - Simple Case Expression in Oracle Database (1/2)
SQL tutorial 49: CASE - Simple Case Expression in Oracle Database (1/2)
Manish Sharma
57 SQL tutorial 50: CASE - Searched Case Expression In Oracle (2/2)
SQL tutorial 50: CASE - Searched Case Expression In Oracle (2/2)
Manish Sharma
58 SQL tutorial 51: DECODE function in Oracle Database By Manish Sharma (RebellionRider)
SQL tutorial 51: DECODE function in Oracle Database By Manish Sharma (RebellionRider)
Manish Sharma
59 Oracle Database Tutorial 52 : Data Pump expdp - How to Export full database using expdp
Oracle Database Tutorial 52 : Data Pump expdp - How to Export full database using expdp
Manish Sharma
60 Oracle Database Tutorial 53 : Data pump expdp - How to Export tablespace in Oracle Database
Oracle Database Tutorial 53 : Data pump expdp - How to Export tablespace in Oracle Database
Manish Sharma

Related Reads

📰
How to Write SQL Queries That Detect Unstable Join Filtering and Inconsistent Results
Learn to write SQL queries that detect unstable join filtering and prevent inconsistent results, improving data analysis reliability
Medium · Machine Learning
📰
How to Write SQL Queries That Detect Unstable Join Filtering and Inconsistent Results
Learn to write SQL queries that detect unstable join filtering and prevent inconsistent results, improving data analysis reliability
Medium · Data Science
📰
Fable 5 Hype: Fangirling with Datasets to Build a Lakers Dashboard
Build a sports team dashboard using datasets and AI for fun and learning
Dev.to · L. Cordero
📰
Imagine waking up one day only to discover your account has been suspended.
Learn about the risks of centralized storage platforms and how to mitigate them
Medium · Data Science
Up next
Google Analytics Alternative For WordPress | AnalyticsWP Tutorial
Matt Tutorials
Watch →