开发者

SQL Server schema-owner permissions

开发者 https://www.devze.com 2022-12-29 06:15 出处:网络
if i do: CREATE SCHEMA [test] AUTHORIZATION [testuser] testuser doesn\'t seem to have any permissions on the schema, is this correct? I thought as the principal that owns the schema, you had full c

if i do:

CREATE SCHEMA [test] AUTHORIZATION [testuser]

testuser doesn't seem to have any permissions on the schema, is this correct? I thought as the principal that owns the schema, you had full control over it?

W开发者_StackOverflowhat permission do i need to grant testuser so that it has full control over the test schema only?

Edit: by "full control" i mean the ability to CRUD tables, views, sprocs etc

Edit: here is my full code:

CREATE DATABASE [testdb]
Go
USE [testdb]

CREATE LOGIN [andrewbdesktop\testuser] FROM WINDOWS
Go

CREATE USER [andrewbdesktop\testuser] FROM LOGIN [andrewbdesktop\testuser]
Go

CREATE SCHEMA [test]
    AUTHORIZATION [andrewbdesktop\testuser]
Go

ALTER USER [andrewbdesktop\testuser] WITH DEFAULT_SCHEMA = [test]

Thanks


By default the schema owner can

  • Grant permissions on any objects within the schema
  • Drop the schema if it is empty
  • Drop any object in the schema

By default the schema owner cannot

  • Create objects in the schema. DDL events are not scoped at the schema level, they are scoped at the database level.


I believe that with your statement, you're making that user the owner of the schema, so it should already have full control over the objects in that schema by default.

If you want more fine-grained control you can do statements like:

GRANT EXECUTE ON SCHEMA::test TO testuser
GRANT INSERT ON SCHEMA::test TO testuser
GRANT SELECT ON SCHEMA::test TO testuser
GRANT UPDATE ON SCHEMA::test TO testuser
GRANT DELETE ON SCHEMA::test TO testuser
0

精彩评论

暂无评论...
验证码 换一张
取 消