DBA_JR
description
Transcript of DBA_JR
![Page 1: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/1.jpg)
DBA JúniorLaboratórios Extra
Hugo [email protected]
Esta obra está licenciada sob a licençaCreative Commons Atribuição-SemDerivados 3.0 Brasil.
Para ver uma cópia desta licença, visite http://creativecommons.org/licenses/by-nd/3.0/br/.
1
![Page 2: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/2.jpg)
Windows Server
2 2
![Page 3: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/3.jpg)
3
Teoria: Versões e Edições
Versões - Windows NT 3.5 - Windows NT 4 - Windows 2000 Server - Windows Server 2003 - Windows Server 2003 R2 - Windows Server 2008 - Windows Server 2008 R2 - Windows Server 2012
Edições Windows 2012 - Foundation - Essentials - Standard - Datacenter
3
![Page 4: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/4.jpg)
4
Prática: Instalação Windows 2008 R2
4
![Page 5: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/5.jpg)
5
Prática: Instalação Windows 2008 R2
5
![Page 6: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/6.jpg)
6
Prática: Instalação Windows 2008 R2
6
![Page 7: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/7.jpg)
7
Prática: Instalação Windows 2008 R2
7
![Page 8: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/8.jpg)
8
Prática: Instalação Windows 2008 R2
8
![Page 9: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/9.jpg)
9
Prática: Instalação Windows 2008 R2
9
![Page 10: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/10.jpg)
10
Prática: Instalação Windows 2008 R2
10
![Page 11: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/11.jpg)
11
Prática: Instalação Windows 2008 R2
11
![Page 12: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/12.jpg)
12
Prática: Instalação Windows 2008 R2
12
![Page 13: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/13.jpg)
13
Prática: Instalação Windows 2008 R2
13
![Page 14: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/14.jpg)
14
Prática: Instalação Windows 2008 R2
14
![Page 15: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/15.jpg)
15
Prática: Instalação Windows 2008 R2
15
![Page 16: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/16.jpg)
16
Prática: Particionamento e Filesystem
16
![Page 17: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/17.jpg)
17
Prática: Particionamento e Filesystem
17
![Page 18: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/18.jpg)
18
Prática: Particionamento e Filesystem
18
![Page 19: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/19.jpg)
19
Prática: Particionamento e Filesystem
19
![Page 20: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/20.jpg)
20
Prática: Particionamento e Filesystem
20
![Page 21: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/21.jpg)
21
Prática: Particionamento e Filesystem
21
![Page 22: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/22.jpg)
22
Prática: Particionamento e Filesystem
22
![Page 23: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/23.jpg)
23
Prática: Particionamento e Filesystem
23
![Page 24: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/24.jpg)
24
Prática: Particionamento e Filesystem
24
![Page 25: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/25.jpg)
25
Prática: Particionamento e Filesystem
25
![Page 26: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/26.jpg)
26
Prática: Particionamento e Filesystem
26
![Page 27: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/27.jpg)
27
Prática: Particionamento e Filesystem
27
![Page 28: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/28.jpg)
28
Prática: Particionamento e Filesystem
28
![Page 29: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/29.jpg)
29
Prática: Particionamento e Filesystem
29
![Page 30: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/30.jpg)
30
Prática: Particionamento e Filesystem
30
![Page 31: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/31.jpg)
31
Prática: Services
31
![Page 32: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/32.jpg)
32
Prática: Services
32
![Page 33: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/33.jpg)
33
Prática: Services
33
![Page 34: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/34.jpg)
34
Prática: CMD
34
![Page 35: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/35.jpg)
35
Prática: CMDC:\Users\Administrator> cd ..C:\Users> cd Adm<TAB>C:\Users\Administrator> cd \C:\> mkdir testeC:\> dirC:\> cd testeC:\teste> notepad teste.txt
Escreva algo no arquivo e salve-o.
C:\teste> copy teste.txt teste02.txtC:\teste> more teste02.txtC:\teste> type teste02.txtC:\teste> cd ..C:\> dirC:\> xcopy testeC:\> dirC:\> del teste.txtC:\> help
35
![Page 36: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/36.jpg)
36
Prática: CMD
C:\Users\Administrator> NET STOP SpoolerC:\Users\Administrator> NET START Spooler
C:\Users\Administrator> HOSTNAME
C:\Users\Administrator> TASKLIST
C:\Users\Administrator> DISKPARTDISKPART> LISTDISKPART> LIST DISKDISKPART> EXIT
36
![Page 37: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/37.jpg)
37
Prática: Programação BATC:\> set MEUDIRETORIO=C:\testeC:\> setC:\> echo %MEUDIRETORIO%C:\> cd %MEUDIRETORIO%C:\teste> notepad teste02.txt
Deixe apenas estas duas linhas no arquivo teste02.txt e salve-o.set MEUDIRETORIO=C:\testedir %MEUDIRETORIO%
C:\teste> REN teste02.txt teste.batC:\teste> teste.bat
Acrescente esta linha no final do arquivo teste.bat e salve-o.teste
C:\teste> teste.batO que aconteceu?
37
![Page 38: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/38.jpg)
38
Prática: Agendamento de TarefasAbra o Task Scheduler.Start -> Administrative Tools -> Task Scheduler
Em Create Basic Task, crie um agendamento para executar diariamente o programa teste.bat.
38
![Page 39: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/39.jpg)
39
Prática: Usuários, Grupos, Domínios
39
![Page 40: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/40.jpg)
40
Prática: Verificação de Desempenho
Inicie o Task Manager.Start, Run, taskmgr
Clique em Resource Monitor.Que informações o Resource Monitor possui, e o Task Manager não?
Inicie o Performance Monitor.Start -> Administrative Tools -> Performance Monitor
Adicione 5 contadores úteis ao Performance Monitor.
40
![Page 41: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/41.jpg)
41
Prática: Event Viewer
Inicie o Event Viewer.Start -> Administrative Tools -> Event Viewer
Analisando o Event Viewer, quando o computador foi inicializado?
Analisando o Event Viewer, quando o segundo disco foi adicionado?
41
![Page 42: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/42.jpg)
42
Teoria: Documentação / Livros
Documentação Windows Serverhttp://technet.microsoft.com/en-us/library/bb625087.aspx
LivroWindows Internals http://technet.microsoft.com/en-us/sysinternals/bb963901.aspx
42
![Page 43: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/43.jpg)
43
Teoria: Certificações / Mercado de Trabalho
- Microsoft Certified Solutions Associate (MCSA) - Microsoft Certified Solutions Expert (MCSE) - Microsoft Certified Solutions Master (MCSM)
43
![Page 44: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/44.jpg)
SQL Server
44 44
![Page 45: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/45.jpg)
45
Teoria: Versões e EdiçõesEdições- Compact- Developer- Express- Standard- Business Intelligence- Enterprise
Versões1.0 (OS/2) 1989 SQL Server 1.01.1 (OS/2) 1991 SQL Server 1.14.21 (WinNT) 1993 SQL Server 4.216.0 1995 SQL Server 6.06.5 1996 SQL Server 6.57.0 1998 SQL Server 7.08.0 2000 SQL Server 20008.0 2003 SQL Server 2000 64-bit Edition9.0 2005 SQL Server 200510.0 2008 SQL Server 200810.5 2010 SQL Server 2008 R211.0 2012 SQL Server 2012
45
![Page 46: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/46.jpg)
46
Prática: Instalação SQL Server
46
![Page 47: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/47.jpg)
47
Prática: Instalação SQL Server
47
![Page 48: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/48.jpg)
48
Prática: Instalação SQL Server
48
![Page 49: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/49.jpg)
49
Prática: Instalação SQL Server
Habilite o Network Discovery.
Pressione a tecla F5 no ambiente de rede, até VBOXSRV aparecer.
Copie o instalador do SQL Server para a VM, e execute-o.
Após a finalização da extração, execute o programa setup.
49
![Page 50: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/50.jpg)
50
Prática: Instalação SQL Server
50
![Page 51: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/51.jpg)
51
Prática: Instalação SQL Server
Inicie o PowerShell.Start -> All Programs -> Acessories -> Windows PowerShell
Habilite o .Net 3.5.PS C:\Users\Administrator> Import-Module ServerManagerPS C:\Users\Administrator> Add-WindowsFeature as-net-framework
Reexecute o programa setup.
51
![Page 52: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/52.jpg)
52
Prática: Instalação SQL Server
52
![Page 53: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/53.jpg)
53
Prática: Instalação SQL Server
53
![Page 54: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/54.jpg)
54
Prática: Instalação SQL Server
54
![Page 55: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/55.jpg)
55
Prática: Instalação SQL Server
55
![Page 56: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/56.jpg)
56
Prática: Instalação SQL Server
56
![Page 57: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/57.jpg)
57
Prática: Instalação SQL Server
57
![Page 58: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/58.jpg)
58
Prática: Instalação SQL Server
58
![Page 59: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/59.jpg)
59
Prática: Instalação SQL Server
59
![Page 60: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/60.jpg)
60
Prática: Instalação SQL Server
60
![Page 61: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/61.jpg)
61
Prática: Instalação SQL Server
61
![Page 62: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/62.jpg)
62
Prática: Instalação SQL Server
62
![Page 63: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/63.jpg)
63
Prática: Instalação SQL Server
63
![Page 64: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/64.jpg)
64
Prática: Instalação SQL Server
64
![Page 65: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/65.jpg)
65
Prática: Instalação SQL Server
65
![Page 66: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/66.jpg)
66
Prática: Instalação SQL Server
66
![Page 67: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/67.jpg)
67
Prática: Instalação SQL Server
67
![Page 68: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/68.jpg)
68
Prática: Instalação SQL Server
68
![Page 69: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/69.jpg)
69
Prática: Instalação SQL Server
69
![Page 70: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/70.jpg)
70
Prática: Instalação SQL Server
70
![Page 71: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/71.jpg)
71
Prática: Serviços
71
![Page 72: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/72.jpg)
72
Prática: Conexão
Inicie o Microsoft SQL Server Management Studio (SSMS).
Efetue logon com SQL Server Authentication, e com o usuário sa.O que deve ser colocado em Server Name?Como você pode se conectar no SQL Server do vizinho?
Clique em New Query.Na tela que se abrir, digite sp_who, e depois pressione F5.
Inicie o CMD.C:\Users\Administrator> sqlcmd -e1> sp_who2> go
Como você pode se conectar no SQL Server com sa via sqlcmd?Como você pode se conectar no SQL Server do vizinho via sqlcmd?C:\Users\Administrator> sqlcmd -?
72
![Page 73: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/73.jpg)
73
Teoria: Arquitetura
73
![Page 74: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/74.jpg)
74
Prática: Parâmetros Instância
No SSMS, clique com o botão direito na instância e selecione Properties.
74
![Page 75: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/75.jpg)
75
Prática: Parâmetros Instância
75
![Page 76: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/76.jpg)
76
Prática: Parâmetros Instância
76
![Page 77: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/77.jpg)
77
Prática: Parâmetros Instância
77
![Page 78: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/78.jpg)
78
Prática: Parâmetros Instância
78
![Page 79: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/79.jpg)
79
Prática: Parâmetros Instância
79
![Page 80: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/80.jpg)
80
Prática: Parâmetros Instância
80
![Page 81: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/81.jpg)
81
Prática: Parâmetros Instância
81
![Page 82: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/82.jpg)
82
Prática: Banco de Dados
82
![Page 83: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/83.jpg)
83
Prática: Banco de Dados
83
![Page 84: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/84.jpg)
84
Prática: Parâmetros Banco de Dados
84
![Page 85: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/85.jpg)
85
Prática: Parâmetros Banco de Dados
85
![Page 86: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/86.jpg)
86
Prática: Modos de Proteção
Simple Recovery Model Bulk-logged Recovery Model Full Recovery ModelAltere o modo de Proteção do banco de dados que você criou para Full.
86
![Page 87: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/87.jpg)
87
Teoria: Estruturas físicas
File Group Primary data files Secondary data files Log files
Logical File Name OS File Name
87
![Page 88: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/88.jpg)
88
Teoria: Estruturas lógicas
Database File Group (Tablespace) Schema Objects (Tables, Indexes, Views, Procedures, Functions, Triggers, etc.)
88
![Page 89: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/89.jpg)
89
Prática: Segurança
User Login Roles
89
![Page 90: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/90.jpg)
90
Teoria: Query, DML, DDL, DCLDDL (Data Definition Language)CREATEALTERDROPTRUNCATE
DCL (Data Control Language)GRANTREVOKE
DML (Data Manipulation Language)SELECTINSERTUPDATEDELETE
TCL (Transaction Control Language)COMMITSAVEPOINTROLLBACKSET TRANSACTION
90
![Page 91: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/91.jpg)
91
Prática: Tabelas, Índices, Views
CREATE TABLE Employee (EmployeeID int, EmpName nvarchar(100), DeptID int);
CREATE TABLE Dept (DeptID int, DeptName nvarchar(100));
CREATE CLUSTERED INDEX IX_Employee ON Employee (EmployeeID);CREATE NONCLUSTERED INDEX IX_EmployeeName ON Employee (EmpName);
CREATE VIEW EmployeesList AS SELECT EmpName FROM Employee;
91
![Page 92: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/92.jpg)
92
Teoria: Procedures
CriaçãoUSE Nerv;GOCREATE PROCEDURE uspGetEmployeeName @EmployeeID intAS SET NOCOUNT ON; SELECT Name FROM Employee WHERE EmployeeID = @EmployeeID;GO
ExecuçãoUSE Nerv;EXECUTE uspGetEmployeeName @EmployeeID = 1GO
92
![Page 93: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/93.jpg)
93
Teoria: Functions
CriaçãoUSE Nerv;GOCREATE FUNCTION NumberOfEmployees (@DeptID int)RETURNS @TotalOfEmployees intAS BEGIN
DECLARE @TotalOfEmployees AS int ;SELECT @TotalOfEmployees = SUM(EmployeeID)FROM EmployeeWHERE DeptID = @DeptID;
RETURN @TotalOfEmployees;END;GO
ExecuçãoSELECT * FROM NumberOfEmployees (2)GO
93
![Page 94: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/94.jpg)
94
Teoria: Triggers
CriaçãoUSE Nerv;CREATE TRIGGER ReminderON DeptAFTER INSERT, UPDATE AS RAISERROR ('Notify Manager', 16, 10);GO
94
![Page 95: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/95.jpg)
95
Prática: PK, FK, Unique, Check, NOT NULL
PKCREATE TABLE Employee (EmployeeID int PRIMARY KEY CLUSTERED, EmpName nvarchar(100), DeptID int);
FKCREATE TABLE Employee (EmployeeID int, EmpName nvarchar(100), DeptID int REFERENCES Dept(DeptID);
UNIQUECREATE TABLE Employee (EmployeeID int PRIMARY KEY, EmpName nvarchar(100) NONCLUSTERED, DeptID int);
CHECKCREATE TABLE Employee (EmployeeID int CHECK (EmployeeID >= 1), EmpName nvarchar(100), DeptID int);
NOT NULLCREATE TABLE Employee (EmployeeID int, EmpName nvarchar(100) NOT NULL, DeptID int);Combine todos estes recursos em seu banco de dados de testes.
95
![Page 96: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/96.jpg)
96
Prática: INSERT, UPDATE, DELETE, SELECT
ExemplosINSERT INTO Employee (EmployeeID, EmpName, DeptID)VALUES (1, 'Ricardo Portilho Proni', 1);
UPDATE Employee SET EmpName = 'Portilho' WHERE EmployeeID = 1;
DELETE FROM Employee WHERE EmployeeID = 2;
SELECT EmpName, DeptID FROM Employee WHERE EmployeeID = 1;
Execute INSERT de 10 registros, UPDATE de 2, DELETE de 2, e 2 SELECTs diferentes.
96
![Page 97: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/97.jpg)
97
Prática: Transações e Isolamento
Execute um UPDATE de seu modelo de dados, em todas os registros da Employee.Abra outra sessão, e execute SELECT em todos os dados da tabela.O que aconteceu?
Repita a operação, mas antes do UPDATE, coloque como abaixo.
BEGIN TRANSACTIONUPDATE ...GO
O que aconteceu?
97
![Page 98: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/98.jpg)
98
Prática: Activity Monitor
Pressione Control + Alt + AEsta visualização é similar a que outra ferramenta?
Execute novamente o cenário de concorrência, e observe o Activity Monitor.
Execute a procedure sp_who.Execute a procedure sp_who2.Qual a diferença das duas procedures?Que informações estas duas procedures possem do Activity Monitor?
98
![Page 99: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/99.jpg)
99
Prática: Backup
Clique com o botão direito no banco de dados de testes, e execute um backup.
Execute o backup também via linha de comando.
BACKUP DATABASE Nerv TO DISK = 'C:\temp\Nerv.BAK'GO
BACKUP LOG Nerv TO DISK = 'C:\temp\Nerv.TRN'GO
99
![Page 100: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/100.jpg)
100
Prática: Rotinas de Manutenção
No SSMS, clique em Management -> Maintenance Plans.Crie um Plano que faça um backup e valide a estrutura do banco de dados de teste.
100
![Page 101: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/101.jpg)
101
Prática: Error Log
101
![Page 102: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/102.jpg)
102
Prática: Error Log
102
![Page 103: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/103.jpg)
103
Teoria: Alta Disponibilidade
Backup e Restore Log Shipping Database Mirroring (async e sync) AlwaysOn Failover Cluster AlwaysOn Availability Group (async e sync)
103
![Page 104: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/104.jpg)
104
Teoria: Documentação / Livros
LivrosSQL Server Internalshttp://www.red-gate.com/community/books/index
SQL Server Blogshttp://technet.microsoft.com/en-us/sqlserver/bb671052.aspx
104
![Page 105: DBA_JR](https://reader033.fdocuments.us/reader033/viewer/2022051115/55cf92c2550346f57b994e75/html5/thumbnails/105.jpg)
105
Teoria: Certificações / Mercado de TrabalhoAtuaisMicrosoft Certified Solutions Associate (MCSA)Microsoft Certified Solutions Expert - Data Platform (MCSE)Microsoft Certified Solutions Expert - Business Intelligence (MCSE)Microsoft Certified Solutions Master - Data Platform(MCSM)
AntigosMCTS: SQL Server 2008, Implementation and MaintenanceMCTS: SQL Server 2008, Database DevelopmentMCTS: SQL Server 2008, Business Intelligence Development and MaintenanceMCITP: Database Administrator 2008MCITP: Database Developer 2008MCITP: Business Intelligence Developer 2008Microsoft Certified Master (MCM)Microsoft Certified Architect (MCA)MCTS: SQL Server 2005MCTS: Microsoft SQL Server 2005, Business Intelligence Development MCITP: Database Developer on SQL Server 2005MCITP: Database Administrator on SQL Server 2005MCITP: Business Intelligence Developer on SQL Server 2005Microsoft Certified Database Administrator – SQL Server 2000
105