How to create schema and use it in table creation

2

I need to create tables, but have this structure. For the tables of Cadasters I put:

Registration.Company, Registration.UF, Registration.Address and so on. For the Logo tables I do: Log.Access, Log.Errors For the Domain tables I would have Domain.Patient Type, Domain.Users, and so on. It turns out that gives me this error:

  

Message 2760, Level 16, State 1, Line 2

     

The specified schema name 'Master' does not exist or you do not have   permission to use it.

This error came from this command (tests only, so no primary keys and etc ...):

create table Cadastro.UF(IDUf integer, Sigla_UF char(2), Nome_Uf varchar(18));

How do I create a schema to use this way?

    
asked by anonymous 13.05.2015 / 18:15

1 answer

3

I believe you are looking for the CREATE SCHEMA

USE MeuDatabase;
GO

CREATE SCHEMA Cadastro AUTHORIZATION MeuUsuario; 
GO

You may also want to give permissions to other users who want to use SCHEMA :

GRANT INSERT ON SCHEMA::Cadastro TO MeuOutroUsuario;
GRANT SELECT ON SCHEMA::Cadastro TO AindaOutroUsuario;
    
13.05.2015 / 18:24