To delete a SQL account, you use a DROP LOGIN statement in Microsoft SQL Server or a DROP USER statement in MySQL, PostgreSQL, and Oracle, after first removing or reassigning anything the account owns. The exact command and the surrounding cleanup differ by database platform, so the first step is to identify which system you're working in and whether you need to remove just the database-level user, the server-level login, or both.

People searching this question usually mean one of two things: removing a database user (the account that connects to a specific database) or removing a server-level login (the account that authenticates to the database server itself). In SQL Server these are separate objects with separate removal commands. In MySQL and PostgreSQL the distinction is smaller: the account is a user, but permissions may still exist in multiple databases. This article covers the major relational database systems, explains the cleanup that has to happen first, and describes what can go wrong if you skip it.

The direct answer, platform by platform

The core removal command is short. The work is in the preparation and the privileges required.

Platform Remove database-level account Remove server-level login Notes
SQL Server DROP USER [name]; DROP LOGIN [name]; You normally drop the user first, then the login, if both exist
MySQL DROP USER 'name'@'host'; Same command MySQL accounts are user-plus-host pairs; the host matters
PostgreSQL DROP ROLE name; or DROP USER name; Same command Roles and users are the same object type; ownership must be reassigned first
Oracle DROP USER name; Not applicable in the same sense Dropping the user removes its schema objects by default

In every system, only a sufficiently privileged account can delete another account. In SQL Server that means membership in sysadmin or the securityadmin role for logins, and db_owner or db_accessadmin for users in a database. In MySQL you need the CREATE USER privilege (which covers DROP USER) or broad administrative rights. In PostgreSQL only superusers or roles with CREATEROLE can drop roles. In Oracle you need DROP USER privilege, typically held by DBA.

The commands look trivial. What makes account deletion a real task is dependency: accounts own objects, hold permissions, own schemas, and appear in jobs, linked servers, and application connection strings. Removing the account before handling those dependencies produces errors or, worse, leaves orphaned objects that nobody can administer cleanly.

SQL Server: logins, users, and the order that matters

SQL Server has a two-layer security model that surprises people coming from other systems. A login authenticates at the server level. A user maps that login into a specific database and receives permissions there. A single login can map to users in several databases.

To remove an account completely, work from the inside out. In each database where the login has a user, connect to that database and run:

If the user owns a schema, SQL Server refuses the drop and tells you the schema is owned by the principal. Reassign ownership first with ALTER AUTHORIZATION ON SCHEMA::[schema_name] TO [dbo]; or to another appropriate principal, then retry. If the user owns objects such as tables or stored procedures, those must be transferred or dropped; SQL Server will not silently delete them, which is a safety feature.

After the database users are gone, drop the server-level login from the master context:

Two common errors explain most failed attempts. Error 15151 ("Cannot drop the login because it does not exist or you do not have permission") usually means you're connected to the wrong database or lack the role. Error 15138 ("The database principal owns a schema and cannot be dropped") means schema ownership must be reassigned first. SQL Server also has contained database users, which authenticate directly in a database without a login; those are dropped with DROP USER alone and have no login to remove.

One safety note: never drop the login mapped to the system administrator or to a service account that SQL Server Agent or applications depend on without confirming the impact. Dropping a login does not automatically disable scheduled jobs that reference it, but those jobs will fail on their next run.

MySQL: account names include the host

MySQL treats an account as a username plus a host, so 'appuser'@'localhost' and 'appuser'@'10.0.0.%' are different accounts with independent passwords and privileges. The removal command must name both parts:

Running DROP USER 'appuser'; without the host is accepted in modern MySQL versions and defaults to the % host, but relying on that default is risky when several accounts share a username. Check first with SELECT user, host FROM mysql.user WHERE user = 'appuser'; so you know exactly which accounts you are removing.

MySQL largely handles the cleanup itself. Dropping an account removes its privilege grants from the grant tables. However, objects the account created in databases remain, and if the account was the definer of stored routines, views, or triggers, those objects can produce errors later when they are invoked. Before dropping, query information_schema.routines and information_schema.views for the definer, and either recreate those objects with a different definer or change it with ALTER DEFINER. Current sessions belonging to the account are not terminated by DROP USER; if you need to force them off, identify their connection IDs and kill them separately.

One practical caution: the account you are logged in as cannot be dropped while it is in use in many configurations, and dropping the account an application uses will cause its next connection attempt to fail. Coordinate with whoever owns the application.

PostgreSQL: roles, ownership, and reassignment

PostgreSQL merged users and groups into roles. DROP USER exists as an alias for DROP ROLE, so either works. The tricky part is ownership. PostgreSQL will not drop a role that still owns database objects or has privileges granted to it, and it reports exactly which objects are in the way.

The standard cleanup pattern is:

REASSIGN OWNED transfers ownership of the role's objects to another role. DROP OWNED removes the remaining privileges the role holds and any objects still owned by it that were not reassigned. Both commands operate on the current database only, so in a cluster with several databases you must connect to each one and repeat the reassignment, or run DROP OWNED in every database before the final DROP ROLE on any database. This multi-database requirement is the most common source of "role cannot be dropped because some objects depend on it" errors.

Also check pg_stat_activity for active sessions by the role; DROP ROLE fails while sessions are connected, and you can terminate them with pg_terminate_backend. Roles with SUPERUSER or membership in other roles need those attributes or memberships revoked first.

Oracle: dropping the user drops the schema

Oracle's model is different enough to warrant its own note. A user in Oracle owns a schema of the same name, and the schema is essentially the collection of objects that user created. DROP USER appuser; therefore fails if the schema contains objects, unless you add CASCADE:

The CASCADE keyword deletes every object in the schema before removing the user. That is fast, and it is exactly why it deserves caution: there is no recycle bin for all object types, the deletion is not reversible in the ordinary sense, and dependent objects in other schemas (such as synonyms or grants) can be left dangling. Verify with SELECT object_type, COUNT(*) FROM dba_objects WHERE owner = 'APPUSER' GROUP BY object_type; before running it, and take an export if the data matters. Oracle does not have a separate server-level login the way SQL Server does; authentication is tied to the user account itself.

Checking dependencies before you drop anything

Regardless of platform, a short pre-flight check prevents most problems. Confirm the account exists and note its exact identifier, including host in MySQL and quoting or case rules elsewhere. Identify objects it owns, privileges it grants, and any scheduled jobs, replication subscriptions, or application configurations that reference it. Find out whether it is currently connected. Decide whether removal is truly the right action.

That last point matters more than it sounds. Deletion is permanent. If the goal is to stop someone from logging in while preserving their objects and audit trail, disabling the account is usually safer: ALTER LOGIN ... DISABLE in SQL Server, ALTER USER ... ACCOUNT LOCK in Oracle, and ALTER USER ... ACCOUNT LOCK in MySQL. Revoking privileges or changing the password achieves a similar practical effect without destroying ownership relationships. In PostgreSQL, revoking LOGIN from a role disables authentication while keeping the role and its objects intact. Deleting should be reserved for accounts that are genuinely obsolete, such as a departed contractor's personal login or a decommissioned application account.

What "delete" does not remove

Even a successful drop leaves traces. Backups taken before the deletion still contain the account and can restore it. Audit logs, error logs, and connection history may reference it. Application configuration files, environment variables, secrets managers, and connection strings will still contain credentials that now fail, and some systems retry aggressively, filling logs with authentication errors. If the account was used in a data integration tool, an ORM configuration, or a reporting service, update those configurations as part of the same change.

Dropping a login in SQL Server also does not remove the corresponding user in databases where one exists under a different name or through role membership, and it does not clean up server-level permissions granted directly to the login, though those disappear with the login itself. In MySQL, dropping the account does not remove databases it created, because MySQL has no per-account schema ownership in the Oracle sense; those databases persist and must be handled separately. Knowing which dependencies each platform actually cleans up, and which it leaves behind, is the difference between a tidy removal and a slow accumulation of orphaned objects.

Permissions, transactions, and a safe sequence

Run account deletions as part of a change-management process rather than ad hoc. A reliable sequence is: identify the account and its host or database mappings, list owned objects and grants, reassign or drop those objects in each relevant database, terminate active sessions if necessary, drop the user in each database, drop the login or role at the server level, then verify with the system catalog views. In SQL Server that verification is SELECT name FROM sys.server_principals WHERE name = 'app_reader'; returning no rows, plus a check of sys.database_principals in each database.

Take a backup or export first, especially for Oracle CASCADE drops and for any account that owns production data. DDL statements like these commit implicitly in most systems, so a rollback is not available once the command succeeds. If your organization requires approvals for production changes, note the account name, the databases affected, and the objects that will be deleted or reassigned in the request.

Finally, distinguish between removing an account and removing access. If a person is leaving the organization, disabling the account and preserving audit records may be the compliant choice; if an application is retiring, a full drop is appropriate. The SQL commands are simple, but the decision about which command to run, and what to clean up around it, is where the real work lies.

Database account management involves access control and potential data loss. The commands above are general guidance; confirm your specific database version's documentation and your organization's security and change-management policies before deleting production accounts, and keep a current backup.