sp_dropalias <loginame>[, force]
<loginame>
是用户的名称(在 master.dbo.syslogins 中),该名称是另一个用户的别名。
force
即使某个别名拥有数据库对象,也可以使用此参数删除该别名。
假设“victoria”在当前数据库中是别名(例如,是数据库所有者的别名),则此语句将“victoria”作为一个具有别名的用户从数据库中删除:
sp_dropalias victoria
删除别名“harry”,它拥有一个过程 namelist。SAP ASE 服务器删除此别名,但会发出一条警告消息:
sp_dropalias harry, force
Warning: You have forced the drop of the alias for login 'harry' which owns objects in the database. This may result in errors when those objects are accessed from or contain references to another database.
Alias user dropped.(return status = 0)
执行 sp_dropalias 过程将从 sysalternates 表中删除用户的替代 suid 映射。
删除了用户的别名后,该用户将不再能够访问为其创建别名的数据库。
可以删除在数据库中拥有对象的用户的别名。在删除登录名之前不需要先删除对象。