-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab_5_Lebedev.sql
88 lines (66 loc) · 1.82 KB
/
lab_5_Lebedev.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
87
88
CREATE DATABASE ÑáîðíàÿDB
ON PRIMARY
( NAME = SbornayaDB, FILENAME = 'D:\labDB\lab5\ÑáîðíàÿDB.mdf' , SIZE = 8192KB , FILEGROWTH = 65536KB )
LOG ON
( NAME = SbornayaDB_log, FILENAME = 'D:\labDB\lab5\ÑáîðíàÿDB_log.ldf' , SIZE = 8192KB , FILEGROWTH = 65536KB );
GO
CREATE TABLE Ñáîðíàÿ (
ðåãèîí INT PRIMARY KEY NOT NULL,
êàïèòàí NVARCHAR(100) NOT NULL
);
INSERT INTO Ñáîðíàÿ(ðåãèîí, êàïèòàí)
VALUES (1, 'Èâàíîâ Èâàí Èâàíû÷')
INSERT INTO Ñáîðíàÿ(ðåãèîí, êàïèòàí)
VALUES (2, 'Âèí Äèçåëü')
SELECT * FROM [Ñáîðíàÿ];
GO
ALTER DATABASE ÑáîðíàÿDB
ADD FILEGROUP ÑáîðíàÿFG;
GO
ALTER DATABASE ÑáîðíàÿDB
ADD FILE
( NAME = 'ÑáîðíàÿData',
FILENAME = 'D:\labDB\lab5\ÑáîðíàÿData.ndf',
SIZE = 5MB,
MAXSIZE = 100MB,
FILEGROWTH = 5MB )
TO FILEGROUP ÑáîðíàÿFG;
GO
ALTER DATABASE ÑáîðíàÿDB
MODIFY FILEGROUP ÑáîðíàÿFG DEFAULT;
GO
CREATE TABLE ÃîÊëóá (
Íàçâàíèå NVARCHAR(100) PRIMARY KEY NOT NULL,
Àäðåñ NVARCHAR(512) NOT NULL,
Ðåãèîí TINYINT NOT NULL,
Ðåéòèíã SMALLINT NULL
);
INSERT INTO ÃîÊëóá(Íàçâàíèå, Àäðåñ, Ðåãèîí, Ðåéòèíã)
VALUES ('Èâàíîâ Èâàí Èâàíû÷', 'ëó÷øåå ìåñòî', 100, 1487)
INSERT INTO ÃîÊëóá(Íàçâàíèå, Àäðåñ, Ðåãèîí, Ðåéòèíã)
VALUES ('sente', 'Ìîñêâà', 0, 1900)
SELECT * FROM ÃîÊëóá;
GO
DROP TABLE ÃîÊëóá;
GO
ALTER DATABASE ÑáîðíàÿDB
MODIFY FILEGROUP [PRIMARY] DEFAULT;
GO
/*
Ýòîò øàã èçìåíÿåò ãðóïïó ôàéëîâ ïî óìîë÷àíèþ îáðàòíî íà PRIMARY. Ýòî îçíà÷àåò, ÷òî âñå íîâûå òàáëèöû,
ñîçäàâàåìûå ïîñëå ýòîãî èçìåíåíèÿ, áóäóò ñîçäàâàòüñÿ â ãðóïïå ôàéëîâ PRIMARY, åñëè íå óêàçàíî èíîå.
*/
ALTER DATABASE ÑáîðíàÿDB
REMOVE FILE ÑáîðíàÿData;
GO
ALTER DATABASE ÑáîðíàÿDB
REMOVE FILEGROUP ÑáîðíàÿFG;
GO
CREATE SCHEMA ÑáîðíàÿÑõåìà;
GO
ALTER SCHEMA ÑáîðíàÿÑõåìà TRANSFER dbo.Ñáîðíàÿ;
GO
DROP TABLE ÑáîðíàÿÑõåìà.Ñáîðíàÿ;
GO
DROP SCHEMA ÑáîðíàÿÑõåìà;
GO