Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server schema-owner permissions

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?

What 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

like image 574
Andrew Bullock Avatar asked May 04 '10 11:05

Andrew Bullock


2 Answers

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.
like image 115
Cory Avatar answered Sep 26 '22 06:09

Cory


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
like image 22
Dave Markle Avatar answered Sep 26 '22 06:09

Dave Markle