Load DDL into schema
I have a tool that generates a DDL script
create table ATTRIBUTE_VALUE (
id int identity not null,
version int null,
);
create table BADGE (
id int identity not null,
version int null,
cms_ci_ref varchar(255) not null unique,
primary key (id)
);
/* more tables */
Notice that the table names are not prefixed by the schema name - I have no control over this. I want to create these tables in myschema
, and am hoping there's some command I ca开发者_如何学编程n execute before loading this script that will set the current schema to myschema
, so that I can then use the DDL without modification.
Something like....
use myschema;
load ddl;
Does SQL Server provide a command like this?
Yes, if using a SQL Server login.
ALTER USER ... WITH DEFAULT_SCHEMA = myschema
Notes from my link:
DEFAULT_SCHEMA cannot be specified for a user who is mapped to a Windows group,
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.
精彩评论