How to create schema and use it in table creation

Asked

Viewed 1,718 times

2

I need to create some tables, but have that structure. For the tables of Registers I put:

Registration.Company, Registration.UF, Registration.Address and so on. For the Logo tables I do: Log.Hits, Log.Errors For the tables of Dominio I would have Dominio.Tipopessoa, Dominio.Tipousuario and so on. It happens to give me this mistake:

Message 2760, Level 16, Status 1, Line 2

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

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

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

How I create a schema to use that way?

1 answer

3


I believe you’re looking for the command CREATE SCHEMA

USE MeuDatabase;
GO

CREATE SCHEMA Cadastro AUTHORIZATION MeuUsuario; 
GO

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

GRANT INSERT ON SCHEMA::Cadastro TO MeuOutroUsuario;
GRANT SELECT ON SCHEMA::Cadastro TO AindaOutroUsuario;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.