新建用户已经指定了一个自定义的架构,在新建表时也可以看到自定义的架构,但新建表时,默认显示的架构还是dbo,我想默认显示自定义的架构,应该怎么做?

解决方案 »

  1.   

    指定数据库用户的默认架构,ALTER USER username WITH DEFAULT_SCHEMA=schemaname同时,数据库用户不能是 sysadmin 服务器角色成员。
      

  2.   


    create login test with password='';
    create user test from login test with default_schema=test;
    create schema test authorization test;execute as user='test'
    select USER_NAME();
    create table tab(id int);
    revertselect * from test.tab
    drop table test.tab;
      

  3.   

    可能是建的步骤有问题,在网上找了一个,解决了,其实真的很简单
    1、新建登录名Login1  2、新建数据库DB1  3、新建DB1的架构Schema1  4、新建BD1的用户User1,登录名对应Login1,默认架构选择Schema1,角色选择db_owner  5、在登录名Login1的属性窗口里选择“用户映射”,勾选DB1,在用户里填写User1,默认架构选择"Schema1"  6、用新建的用户登陆,至此,新建表名会是Schema1.Table1,其他对象也如此
    原文