-
Notifications
You must be signed in to change notification settings - Fork 2
/
sqlserver2022-security-ledger3_ledgerdb.sql
86 lines (57 loc) · 1.35 KB
/
sqlserver2022-security-ledger3_ledgerdb.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
SQL Server 2022
SQL Ledger
- ledger database
https://www.kursysql.pl
*/
USE tempdb
GO
DROP DATABASE IF EXISTS EmployeeProtectedData
GO
CREATE DATABASE EmployeeProtectedData
WITH LEDGER = ON
GO
USE EmployeeProtectedData
/*
Tworzenie tabel
*/
DROP TABLE IF EXISTS dbo.EmployeeRate
CREATE TABLE dbo.EmployeeRate (
BusinessEntityID int PRIMARY KEY IDENTITY,
Firstname nvarchar(50),
Lastname nvarchar(50),
HireDate date,
JobTitle nvarchar(50),
Rate money,
PayFrequency tinyint
)
DROP TABLE IF EXISTS dbo.EmployeeBonus
CREATE TABLE dbo.EmployeeBonus
(
EmployeeBonusID int PRIMARY KEY IDENTITY,
BusinessEntityID int,
BonusAwarded money,
BonusDate datetime DEFAULT GETDATE()
)
DROP TABLE IF EXISTS dbo.EmployeeBonus
CREATE TABLE dbo.EmployeeBonus
(
EmployeeBonusID int PRIMARY KEY IDENTITY,
BusinessEntityID int,
BonusAwarded money,
BonusDate datetime DEFAULT GETDATE()
)
WITH (LEDGER = ON (APPEND_ONLY = ON))
DROP TABLE IF EXISTS dbo.RegularTable
-- ! Msg 37420, Level 16, State 1, Line 67
-- ! LEDGER = OFF cannot be specified for tables in databases that were created with LEDGER = ON.
CREATE TABLE dbo.RegularTable
(
EmployeeBonusID int PRIMARY KEY IDENTITY,
BusinessEntityID int,
BonusAwarded money,
BonusDate datetime DEFAULT GETDATE()
)
WITH (LEDGER = OFF)
--> Azure SQL - Enable ledger database