ALTER USER

Rename a database user or change its default schema.

Syntax
      ALTER USER user WITH [NAME = new_user_name] [, DEFAULT_SCHEMA = schema ]

Key
   user          Name for the user in this database.
   new_user_name New name for this user.
   schema        The first schema that will used to resolve object names for user.
                 default schema = dbo

All members of the sysadmin fixed server role have a default schema of dbo.

A user that is not mapped to a SQL Server login may connect to other databases as guest, this just requires GRANT CONNECT TO guest;

Examples

ALTER USER user87 WITH NAME = user143;

ALTER USER user21 WITH NAME = user144, DEFAULT_SCHEMA = Sales;
GO

"My friend, there are two kinds of people in the world, Those with guns and those who dig." - The Good, The Bad, and The Ugly

Related commands:

sp_change_users_login auto_fix,'username' - Map an existing database user to a SQL Server login.
CREATE LOGIN
CREATE USER
DROP USER
Equivalent Oracle command: ALTER USER


© Copyright SS64.com 1999-2014
Some rights reserved