Создаем БД макс параметрами drop database test удаление БД test --drop

 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
Создаем БД с макс. параметрами
drop database test удаление БД "test"
--drop database test
--create database test
--on
--primary
--(name=file1,filename='d:\db\file1.mdf',size=4mb,maxsize=8mb,filegrowth=1mb),
--(name=file2,filename='d:\db\file2.ndf',size=2mb,maxsize=4mb,filegrowth=20%),
--(name=file3,filename='d:\db\file3.ndf',size=1mb,maxsize=unlimited,filegrowth=25%)
--log on
--(name=logfile1, filename='d:\db\logfile1.ldf',size=4mb,maxsize=8mb,filegrowth=10%)
--use master exec sp_helpdb
--sp_helpdb test
--sp_helpdb
--drop database test
create database test
on
primary
(name=file1,filename='d:\db\file1.mdf',size=4mb,maxsize=8mb,filegrowth=1mb),
filegroup group2
(name=file2,filename='d:\db\file2.ndf',size=2mb,maxsize=4mb,filegrowth=20%),
filegroup group3
(name=file3,filename='d:\db\file3.ndf',size=1mb,maxsize=unlimited,filegrowth=25%)
log on
(name=logfile1, filename='d:\db\logfile1.ldf',size=4mb,maxsize=8mb,filegrowth=10%)
--use master exec sp_helpdb
--sp_helpdb test
--sp_helpdb
***************************************************************
create database test
on
primary
(name=file1,filename='D:\db\mdf\file1.mdf',size=4mb,maxsize=8mb,filegrowth=1mb),
(name=file2,filename='D:\db\ndf\file2.ndf',size=2mb,maxsize=4mb,filegrowth=20%)
log on
(name=logfile1, filename='D:\db\ldf\logfile1.ldf',size=4mb,maxsize=8mb,filegrowth=10%),
(name=logfile2, filename='D:\db\ldf2\logfile2.ldf',size=4mb,maxsize=8mb,filegrowth=10%)
*_**_**_**_**_**_**_**_**_**_**_**_**_**_**_**_**_**_**_**_**_*
/*use master exec sp_detach_db 'test'*/
use master exec sp_attach_db 'db2', 'D:\db2\mdf\file1.mdf','D:\db2\ndf\file2.ndf','D:\db2\ldf\logfile1.ldf','D:\db2\ldf2\logfile2.ldf'
use master sp_helpdb 'test'
/*sp_attach_db присоединение БД
sp_detach_db отсоединение БД*/
=================================================================
Работа с таблицами
Проектирование таблиц
drop database test
create database test
use test
create table tab1
(f1 int identity primary key nonclustered, f2 nvarchar (10) not null, f3 nvarchar (20) not null, f4 nvarchar (30) not null, unique(f2,f3))
use test exec sp_help
use test exec sp_help 'tab1'