Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering PostgreSQL 10

You're reading from   Mastering PostgreSQL 10 Expert techniques on PostgreSQL 10 development and administration

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788472296
Length 428 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (19) Chapters Close

Title Page
Packt Upsell
Contributors
Preface
1. PostgreSQL Overview FREE CHAPTER 2. Understanding Transactions and Locking 3. Making Use of Indexes 4. Handling Advanced SQL 5. Log Files and System Statistics 6. Optimizing Queries for Good Performance 7. Writing Stored Procedures 8. Managing PostgreSQL Security 9. Handling Backup and Recovery 10. Making Sense of Backups and Replication 11. Deciding on Useful Extensions 12. Troubleshooting PostgreSQL 13. Migrating to PostgreSQL 1. Other Books You May Enjoy Index

Reassigning objects and dropping users


After assigning permissions and restricting access, it can happen that users will be dropped from the system. Unsurprisingly, the commands to do that are the DROP ROLE and DROP USER commands:

test=# \h DROP ROLE Command:  DROP ROLE 
Description: remove a database role 
Syntax: 
DROP ROLE  [ IF EXISTS ] name  [, ...]

Let's give it a try:

test=# DROP ROLE joe;
ERROR:  role  "joe"  cannot be dropped because some  objects depend on it 
DETAIL:  target of policy joe_pol_3 on table t_person  
target of policy joe_pol_2 on table t_person 
target of policy joe_pol_1 on table t_person  
privileges for table t_person 
owner of table t_user 
owner of sequence t_user_id_seq 
owner of default privileges on new relations belonging to role joe in schema public 
owner of table t_useful

PostgreSQL will issue error messages because a user can only be removed if everything has been taken away from him. This makes sense for this reason: just suppose somebody owns a table....

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime
Visually different images