-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcleanup.sql
More file actions
46 lines (31 loc) · 1.45 KB
/
Copy pathcleanup.sql
File metadata and controls
46 lines (31 loc) · 1.45 KB
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
-- MANUAL, DESTRUCTIVE. Nothing in this repo runs this file.
--
-- These are ad-hoc helpers kept for convenience. Read before running: the
-- statements below drop the tpcc and tpch databases outright and resize model,
-- with no IF EXISTS guards and no USE statement, so they act on whichever
-- instance your session is connected to. Run individual statements, not the
-- whole file.
-- Force disconnect all sessions and drop TPC-C database
ALTER DATABASE tpcc SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE tpcc;
GO
-- Force disconnect all sessions and drop TPC-H database
ALTER DATABASE tpch SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE tpch;
GO
SELECT @@VERSION
ALTER DATABASE MODEL SET RECOVERY SIMPLE
-- set model to 1gb for file and log
ALTER DATABASE model MODIFY FILE (NAME = modeldev, SIZE = 1GB);
ALTER DATABASE model MODIFY FILE (NAME = modellog, SIZE = 1GB);
select name, recovery_model_desc from sys.databases where name in ('tpcc', 'tpch', 'model');
BACKUP DATABASE tpcc TO DISK = 'tpcc.bak'
WITH INIT, SKIP, NOREWIND, NOUNLOAD, STATS = 10, COMPRESSION;
BACKUP DATABASE tpch TO DISK = 'tpch.bak'
WITH INIT, SKIP, NOREWIND, NOUNLOAD, STATS = 10, COMPRESSION;
RESTORE DATABASE tpch FROM DISK = 'tpch.bak' WITH REPLACE;
RESTORE DATABASE tpcc FROM DISK = 'tpcc.bak' WITH REPLACE;
sp_readerrorlog;
USE [master]
RESTORE DATABASE [tpcc] FROM DISK = N'/var/opt/mssql/backups/tpcc.bak'
WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5