пятница, 22 марта 2013 г.

Что такое Data Control Language (DCL)


-- Что такое Data Control Language (DCL)


IF DB_ID('Specialist') IS NULL
CREATE DATABASE Specialist
GO
USE Specialist
IF OBJECT_ID('Course','U') IS NULL
CREATE TABLE Course
(
    CourseID INT
    , Name NVARCHAR(50)
    , Duration INT
    , Price MONEY
);


CREATE LOGIN MyUser
WITH PASSWORD = 'Pa$$w0rd'

USE Specialist

CREATE USER MyUser
FROM LOGIN MyUser


SELECT * FROM sys.tables


GRANT SELECT ON Course TO MyUser

REVOKE SELECT ON Course FROM MyUser