SQL 服务器架构和默认架构 [英] SQL server schema and default schema

查看:77
本文介绍了SQL 服务器架构和默认架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有一个架构定义.除了现在每次执行 sql 语句时,我都必须提供架构...SELECT * FROM [myschema].table

I have a schema define in my database. Except now everytime I do a sql statement I have to provide the schema ... SELECT * FROM [myschema].table

我使用 management studio 为我的用户设置了默认架构,并运行了ALTER USER myUser WITH DEFAULT_SCHEMA [myschema]在编写没有架构的查询时,我仍然得到无效的对象表"(SELECT * FROM table)

I set the default schema for my user using management studio and also ran the ALTER USER myUser WITH DEFAULT_SCHEMA [myschema] and I still get the invalid object 'table' when writing a query without the schema (SELECT * FROM table)

有没有办法写SELECT * FROM table而不必一直指定模式名称?

Is there a way to write SELECT * FROM table without having to specify the schema name all the time?

它在 SQL 2005 上使用 SQL Management Studio.

It's on SQL 2005 using SQL Management Studio.

推荐答案

用户是否是 SA,如果是这样,将不起作用,根据 documentation SA 用户始终默认使用 dbo 架构.

Is the user an SA, if so it will not work, according to the documentation SA users are always defaulted to the dbo schema.

DEFAULT_SCHEMA 的值被忽略如果用户是sysadmin 固定服务器角色.全部sysadmin 固定服务器的成员角色的默认架构为 dbo.

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.

这篇关于SQL 服务器架构和默认架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆