如何在 SQL Server 2005 中设置数据库的默认架构?
问题描述:
以下行有效:
SELECT * FROM [myschema].users
但这不会:
SELECT * FROM users
答
默认架构是特定于用户的:
A default schema is user-specific:
USE yourDatabase;
ALTER USER [yourUser] WITH DEFAULT_SCHEMA = myschema;
有关ALTER TABLE的更多信息a> for SQL 2005 也可能对您有所帮助.
More information about the ALTER TABLE for SQL 2005 might help you as well.
由于这是特定于用户的,如果您有多个用户,则需要为要更新其默认架构的每个用户执行此查询(在每个数据库上).
As this is user-specific, if you have multiple users, you will need to execute this query (on each database) for each user whose default schema you want to update.
需要注意的是:
The value of DEFAULT_SCHEMA is ignored if the user is a member of the sysadmin
fixed server role. All members of the sysadmin fixed server role have a default
schema of dbo.